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?

Kirk Beard
  • 9,569
  • 12
  • 43
  • 47
Juliatzin
  • 18,455
  • 40
  • 166
  • 325
  • 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. – Naktibalda Mar 22 '16 at 10:50
  • 1
    I don t understand. I m new to codecption. Can you please detail? – Juliatzin Mar 22 '16 at 15:16

2 Answers2

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);
}
gvlasov
  • 18,638
  • 21
  • 74
  • 110
  • 1
    It is better to make it to do nothing, because your function makes test take X seconds longer for no good reason. – Naktibalda Sep 11 '16 at 20:34
  • @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. – gvlasov Sep 11 '16 at 21:59
  • 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. – Naktibalda Sep 12 '16 at 08:56
2

Change class_name: WebGuy to class_name: AcceptanceTester

Naktibalda
  • 13,705
  • 5
  • 35
  • 51