I'm doing this in my page object:
try{
I.selectOption(this.SELECT, this.OPTION);
}
catch(error){
I.say('Option missing, but thats sometimes expected ' + error);
}
But it still fails the test when the locator doesn't match an option element.
I want to catch and continue the test, without failing.
UPDATE:
It looks like it depends on what's in the try block.
If I put an assertion there, like I.see('something');
Then the catch block is not skipped. But non-assertions in the try block, like I.selectOption('something')
throw errors which are not caught by the catch.
Try-catch should be performed on a promise chain. I think you can get it this way:
I.selectOption(this.SELECT, this.OPTION).catch(() => I.say(''));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With