我需要使用函数验证元素是否出现在屏幕上。如果不是,它会执行另一个函数。例如:
- 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']"}
});
}发布于 2020-03-19 02:08:02
您可以使用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
}https://stackoverflow.com/questions/60622740
复制相似问题