根据OpenTest中先前断言的结果执行条件逻辑



我需要使用函数验证元素是否在屏幕上。如果没有,它将执行另一个功能。例如:

- description: validation function
script: |
$runAction("org.getopentest.selenium.NavigateTo", {
url: "https://translate.google.com/"
}),;
if((
$runAction('org.getopentest.selenium.AssertElementVisible',
{
"locator": {css: "[id='sugg-item-en']"},
})
) == 'true'){
} else {
$runAction('org.getopentest.selenium.AssertElementVisible',
{
"locator": {css: "[id='sugg-item-pt']"}
});
}

您可以使用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
}

相关内容

  • 没有找到相关文章

最新更新