0
votes

I want to write a generic method that at certain times I can just say

$I->amOnPage('/');
$I->dontSeeAnyWarningsOrErrors ();

But I am not succeeding. I've been using codeception for just a few hours now, so I could be easily missing something, but searching their site, their github repo and SO hasn't turned up anything to help me.

Here's what I've tried (result: "ErrorException: Missing argument 1 for AcceptanceTester::dontSeeAnyWarningsOrErrors()"):

class AcceptanceHelper extends \Codeception\Module
{
    public function dontSeeAnyWarningsOrErrors ()
    {
        $this->dontSee ('PHP Warning');
        $this->dontSee ('PHP Error');
        $this->dontSee ('PHP Notice');
        $this->dontSee ('There was a website error');
        $this->dontSee ('Parse error: syntax error');
        $this->dontSee ('Call Stack:');
    }
}

If I call it like this:

$I->amOnPage('/');
$I->dontSeeAnyWarningsOrErrors (null);

Then I get "Fatal error: Call to undefined method Codeception\Module\AcceptanceHelper::dontSee()"

Also (method doesn't exist; something I found in the core files):

$res = $this->proceedSee('PHP Warning', null);
       $this->assertNot($res);

Also ("Undefined property $session" (using Selenium with Firefox)):

$page = $this->getModule('WebDriver')->session->getPage();

Also, when I tried to use "dontSeeAnyWarningsOrErrors" it complains if I don't add an argument (in the call) when I haven't defined any arguments.

Thank you, Hans

1

1 Answers

0
votes

I managed it with this:

$I->dontSeeAnyWarningsOrErrors ($I);

And then:

class AcceptanceHelper extends \Codeception\Module 
{ 
    public function dontSeeAnyWarningsOrErrors ($browser) 
    { 
        $browser->dontSee ('PHP Warning'); 
        $browser->dontSee ('PHP Error'); 
        $browser->dontSee ('PHP Notice'); 
        $browser->dontSee ('There was a website error'); 
        $browser->dontSee ('Parse error: syntax error'); 
        $browser->dontSee ('Call Stack:'); 
    } 
}