Javascript 根据OpenTest中先前断言的结果执行条件逻辑
我需要使用函数验证屏幕上是否有元素。如果没有,它将执行另一个功能。 例如:Javascript 根据OpenTest中先前断言的结果执行条件逻辑,javascript,opentest,Javascript,Opentest,我需要使用函数验证屏幕上是否有元素。如果没有,它将执行另一个功能。 例如: 您可以使用try…catch语句: - description: Validation function script: | try { $runAction('org.getopentest.selenium.AssertElementVisible', { "locator": {css: "[id='sugg-item-en']"}, });
您可以使用
try…catch
语句:
- description: Validation function
script: |
try {
$runAction('org.getopentest.selenium.AssertElementVisible', {
"locator": {css: "[id='sugg-item-en']"},
});
// If element was found (the assert succeeded), execution continues here
} catch {
// If element was NOT found (the assertion failed), execution continues here
}
- description: Validation function
script: |
try {
$runAction('org.getopentest.selenium.AssertElementVisible', {
"locator": {css: "[id='sugg-item-en']"},
});
// If element was found (the assert succeeded), execution continues here
} catch {
// If element was NOT found (the assertion failed), execution continues here
}