Codeception: [RuntimeException] Call to undefined method AcceptanceTester::wait

早过忘川 提交于 2019-12-10 16:47:49

问题


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?


回答1:


Change class_name: WebGuy to class_name: AcceptanceTester




回答2:


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);
}


来源:https://stackoverflow.com/questions/36093658/codeception-runtimeexception-call-to-undefined-method-acceptancetesterwait

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!