Warm tip: This article is reproduced from serverfault.com, please click

Use CodeCeption assertion in conditional (if) statement

发布于 2014-10-03 17:28:08

I'm totally new with CodeCeption.

I want to do an action/assertion depending on another assertion result, like this:

if ($I->see('message')){

    $I->click('button_close');

}

Is something like that possible? I tried, but doesn't work. Probably the assertion result doesn't apply to IF, but is there any alternative?

Thanks in advance!

IMPORTANT UPDATE:

Finally Codeception now has the function performOn!! http://codeception.com/docs/modules/WebDriver#performOn

Questioner
Borjovsky
Viewed
0
DAB 2015-12-18 10:55:34

I had this same issue. Although it's not ideal, you can do this:

try {
    $I->see('message');
    // Continue to do this if it's present
    // ...
} catch (Exception $e) {
    // Do this if it's not present.
    // ...
}