我正在准备一个脚本,通过selenium机器人框架在网站中自动化测试。
有一个XPath返回${EMPTY}
并且我尝试分配0,但它显示以下错误。
Evaluating expression ' == ''' failed: syntaxerror: no viable alternative at input '==' (<string>, line1)
这是我写的:
column1 | column2 | column3 | column4
-------------------------------------------------------------------------
${var1}= | Set Variable if | ${var1}=='${EMPTY}' | ${var1}==0
请您帮我解决一下这个问题吗?
谢谢 瑜珈
答案 0 :(得分:1)
从技术上讲,内置变量${EMPTY}
周围不需要单引号。但是,如果您确实选择使用它们,则比较语句的两侧应该是一致的。
${var1} is ${EMPTY}
或
'${var1}'=='${EMPTY}'
因此,您的关键字语句应如下所示:
${var1}= Set Variable If ${var1} is ${EMPTY} 0
答案 1 :(得分:0)
我可能错了,因为我没有多少经验,但我认为你的问题在条件陈述中。试图修改:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "x.y"
minSdkVersion 15
targetSdkVersion 18
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
manifest.srcFile '/src/main/AndroidManifest.xml'
java.srcDirs = ['/src/main/java', '.apt_generated']
aidl.srcDirs = ['/src/main/aidl', '.apt_generated']
assets.srcDirs = ['/src/main/assets']
res.srcDirs =
[
'/src/main/res',
'/src/main/res/layout',
'/src/main/res/layout/cards',
'/src/main/res/layout/intro',
'/src/main/res/layout/customviews',
'/src/main/res/layout/droppy'
]
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.alibaba:fastjson:1.2.6'
compile 'com.marvinlabs:android-floatinglabel-widgets:1.6.1@aar'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-gcm:7.+'
compile 'com.parse.bolts:bolts-android:1.2.0'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.0'
compile 'com.prolificinteractive:material-calendarview:0.4.0'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.0'
compile 'com.google.android.gms:play-services-maps:7.+'
compile 'uk.me.lewisdeane.ldialogs:ldialogs@aar'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'co.uk.rushorm:rushandroid:1.1.7'
// Check https://github.com/panwrona/DownloadProgressBar
//compile 'com.github.panwrona:DownloadProgressBar:1.1'
// Check https://github.com/TakeoffAndroid/MaterialDialogBottomSheet
compile project(':supertoasts')
compile project(':library')
compile project(':Droppy')
compile project(':tutorial_view')
compile project(':appintrolib')
compile project(':Slidr')
compile project(':circularprogressbutton')
compile project(':android_week_view')
compile 'com.google.guava:guava:19.0-rc1'
要为此添加一些解释,它应该意味着如果var1确实为空,它将把var1的值设置为0.如果它不是空的,它将保留var1来自的任何值。的XPath。
我建议您仔细阅读以确保您已经掌握它:http://robotframework.org/robotframework/latest/libraries/BuiltIn.html