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

php-在条件 (if) 语句中使用 CodeCeption 断言

(php - Use CodeCeption assertion in conditional (if) statement)

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

我对 CodeCeption 完全陌生。

我想根据另一个断言结果执行操作/断言,如下所示:

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

    $I->click('button_close');

}

这样的事情可能吗?我试过了,但不起作用。可能断言结果不适用于 IF,但还有其他选择吗?

提前致谢!

重要更新:

Codeception终于有了这个功能performOn!! http://codeception.com/docs/modules/WebDriver#performOn

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

我有同样的问题。虽然它并不理想,但你可以这样做:

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