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!
Finally Codeception now has the function performOn
!! http://codeception.com/docs/modules/WebDriver#performOn
assertFileIsReadable. Asserts that a file exists and is readable.
Codeception is a framework used for creating tests, including unit tests, functional tests, and acceptance tests. Despite the fact that it is based on PHP, the user needs only basic knowledge for starting work with the framework, thanks to the set of custom commands offered by Codeception.
Writing acceptance tests is like describing a tester's actions in PHP. They are quite readable and very easy to write. If you need to access the database, you can use the Db Module.
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. // ... }
In tests/_support/AcceptanceHelper.php
add additional method
function seePageHasElement($element) { try { $this->getModule('WebDriver')->_findElements($element); } catch (\PHPUnit_Framework_AssertionFailedError $f) { return false; } return true; }
Then to test in your acceptance test use:
if ($I->seePageHasElement("input[name=address]")) { $I->fillField("input[name=address]", "IM"); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With