Reputation: 1
I need to validate if an element is on the screen using a function. If not, it performs another function. eg:
- 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']"}
});
}
Upvotes: 0
Views: 127
Reputation: 12327
You can use a try...catch
statement:
- 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
}
Upvotes: 0