【问题标题】:Codeception: [RuntimeException] Call to undefined method AcceptanceTester::waitCodeception:[RuntimeException] 调用未定义的方法 AcceptanceTester::wait
【发布时间】:2017-09-07 23:09:28
【问题描述】:

我正在使用 Codeception 进行我的第一次验收测试。

当我使用 wait()waitForElement() 运行测试时,我收到以下消息:

[RuntimeException] Call to undefined method AcceptanceTester::wait  

这是我的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'

这是我的测试:

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

我从 official doc得到它

我也确保执行:

vendor/bin/codecept build

有什么问题?

【问题讨论】:

  • 您的配置文件声明了 WebGuy 并使用 Codeception 2.0(或更早版本)配置样式,但您的测试中使用了 AcceptanceTester。它们不相关。
  • 我不明白。我是编解码新手。能详细点吗?

标签: laravel codeception acceptance-testing


【解决方案1】:

我在缺少wait() 方法时遇到了类似的问题。问题是我使用的是PhpBrowser 而不是WebDriver,而PhpBrowser 没有提供这种方法。在您的测试器类中自己实现它是微不足道的:

public function wait($seconds) {
    sleep($seconds);
}

【讨论】:

  • 最好让它什么都不做,因为你的函数无缘无故地让测试多花 X 秒。
  • @Naktibalda 为什么你确定我没有充分的理由?例如,我可能正在等待我的测试邮件服务器传输电子邮件。我可能正在等待浏览器之外发生的任何事情。
  • WebDriver 中的 wait() 用于浏览器中的延迟效果。使用 PhpBrowser 时没有这样的效果。当您实际上需要在两个模块中等待时,最好使用不同的方法名称。
【解决方案2】:

class_name: WebGuy 更改为class_name: AcceptanceTester

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-23
    • 1970-01-01
    • 2021-07-16
    • 1970-01-01
    • 2016-08-04
    • 2013-03-27
    相关资源
    最近更新 更多