Codeception test fails even though try-catch Codeception test fails even though try-catch selenium selenium

Codeception test fails even though try-catch


If you have your tests in a namespace (and you should) the code will try to catch an exception from that namespace.I.e.

namespace MyTest;try {    $I->click(self::$buttonAddNewAddress);} catch (Exception $e) {    $I->comment('This address will be the first one');}

This will only catch a \MyTest\Exception.

You need to add \ to your code.

namespace MyTest;try {    $I->click(self::$buttonAddNewAddress);} catch (\Exception $e) {    $I->comment('This address will be the first one');}