I am using nightwatch isVisible
command to check for the element visible. The scenario here is , If the element is visible, i want to click that element and continue the test. if the element is not visible, i don't want to click the element and I still want to continue the test.
Therefore , I cannot wrap the code in else block.
The problem here is , once the condition has met , The test doesn't continue. I believe it couldn't come out from that condition. Please find my code below and provide your suggestions.
`
const result = await this.myAccountTest.isVisible('@btnremove');
console.log('isVisible result', result);
if(await result.value==true)
{
await this.myAccountTest.remove();
await this.myAccountTest.clickConfirm();
}
// rest of the code to continue
await this.myaccountTest.create();
//more code`
I think you are using await at wrong places. Maybe you can simply code as below.
const result = await this.myAccountTest.isVisible('@btnremove');
console.log('isVisible result', result);
if (result.value) {
this.myAccountTest.remove();
this.myAccountTest.clickConfirm();
}
// rest of the code to continue
await this.myaccountTest.create();