In codeception, I want check if an element exist in the page and do another test if the first element exist. I can do that simply :
// $I is a AcceptanceTester Object and extends \Codeception\Actor class
try{
    $I->see('.firstElement');
}catch(ElementNotFound $e){
    // do some actions
}
    // do some anothers actions
But If I do that, in the report file I can see the line "I see '.firstElement'". I don't want see this test in this report. 
My question : How can I call a \Codeception\Actor method quietly ? I just want do a simple DOM element html check and not print this action into the generated report
You can create a simple helper module to check elements existence. It can use WebDriver module or PhpBrowser module to elements finding. For example:
class ElementChecker extends \Codeception\Module
{
    public function checkExistence($locator)
    {
        $elements = $this->getModule('WebDriver')->_findElements($locator);
        return !empty($elements);
    }
},
After it, you should add this helper to your codeception configuration. For example:
actor: SomeTester
modules:
    enabled:
        # some modules
        - ElementChecker
And new methods will be included in the tester class. You can use them:
if ($I->checkExistence('.firstElement')) {
    // some code
}
Also, you can read more about helpers in the official documentation
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