Codeception: [RuntimeException] Call to undefined method AcceptanceTester::wait
Asked Answered
E

2

6

I'm making my first acceptance test with Codeception.

When I run my test with wait() or waitForElement(), I get this message:

[RuntimeException] Call to undefined method AcceptanceTester::wait  

Here is my acceptance.yml

# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate     suite.

class_name: WebGuy
modules:
enabled:
    - WebDriver
    - \Helper\Acceptance
config:
    WebDriver:
        url: 'http://rh.dev'
        browser: 'firefox'

And here is my test:

$I = new AcceptanceTester($scenario);
$I->wantTo('Register my profile for the first time');
$I->amOnPage('/register');
$I->fillField('name', $person->name);
$I->wait(3); // secs
$I->fillField('lastName', $person->lastName);

I got it from official doc

I also made sure to execute:

vendor/bin/codecept build

What's the problem?

Ellinger answered 18/3, 2016 at 20:27 Comment(2)
Your configuration file declares WebGuy and uses Codeception 2.0 (or earlier) configuration style, but AcceptanceTester is used in your test. They are not related.Ophite
I don t understand. I m new to codecption. Can you please detail?Ellinger
O
2

Change class_name: WebGuy to class_name: AcceptanceTester

Ophite answered 22/3, 2016 at 16:46 Comment(0)
U
6

I had a similar problem with the missing wait() method. The problem was I was using PhpBrowser instead of WebDriver, and PhpBrowser doesn't provide that method. It is trivial to implement it yourself in your tester class:

public function wait($seconds) {
    sleep($seconds);
}
Uitlander answered 9/9, 2016 at 22:39 Comment(3)
It is better to make it to do nothing, because your function makes test take X seconds longer for no good reason.Ophite
@Ophite Why are you sure that I don't have a good reason? I may be waiting for my test mail server to transfer an email, for example. I may be waiting for anything that happens outside the browser.Uitlander
wait() in WebDriver is for delayed effects in the browser. There are no such effects when PhpBrowser is used. It would be better to use a different method name when you actually need to wait in both modules.Ophite
O
2

Change class_name: WebGuy to class_name: AcceptanceTester

Ophite answered 22/3, 2016 at 16:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.