我对CodeCeption完全是新手。
我想根据另一个断言结果执行操作/断言,如下所示:
if ($I->see('message')){
$I->click('button_close');
}
这样的事情有可能发生吗?我试过了,但没用。可能断言结果不适用于IF,但是否有其他选择?
提前感谢!
重要更新:
最后,Codeception现在有了函数performOn
!!http://codeception.com/docs/modules/WebDriver#performOn
发布于 2015-12-18 10:55:35
我也有同样的问题。虽然这并不理想,但您可以这样做:
try {
$I->see('message');
// Continue to do this if it's present
// ...
} catch (Exception $e) {
// Do this if it's not present.
// ...
}
发布于 2016-04-15 19:45:50
在tests/_support/AcceptanceHelper.php
中添加附加方法
function seePageHasElement($element)
{
try {
$this->getModule('WebDriver')->_findElements($element);
} catch (\PHPUnit_Framework_AssertionFailedError $f) {
return false;
}
return true;
}
然后,要在验收测试中进行测试,请使用:
if ($I->seePageHasElement("input[name=address]")) {
$I->fillField("input[name=address]", "IM");
}
发布于 2014-11-12 21:46:35
您可以使用类似这样的解决方法或类似的组合:
$tmp = $I->grabTextFrom('SELECTOR');
if ($tmp == 'your text') {
$I->click('button_close');
}
https://stackoverflow.com/questions/26183792
复制相似问题