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?

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. Commented Mar 22, 2016 at 10:50
  • 1
    I don t understand. I m new to codecption. Can you please detail? Commented Mar 22, 2016 at 15:16

2 Answers 2

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);
}
Sign up to request clarification or add additional context in comments.

3 Comments

It is better to make it to do nothing, because your function makes test take X seconds longer for no good reason.
@Naktibalda 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.
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.
2

Change class_name: WebGuy to class_name: AcceptanceTester

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.