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.
await
before theI.selectOption
call in order for the failure to be caught by thecatch
. (2) I have a hunch that this is because CodeceptJS uses a global promise chain. So the internal global promise fails if the I.* fails, regardless of whether it's caught. – Congress