2016-03-18 15 views
2

我正在使用Codeception進行我的第一次驗收測試。Codeception:[RuntimeException]調用未定義的方法AcceptanceTester :: wait

當我跑我的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 

什麼問題?

+0

您的配置文件聲明WebGuy並使用Codeception 2.0(或更早)配置風格,但AcceptanceTester在您的測試中使用。他們不相關。 – Naktibalda

+0

我不明白。我對codecption很陌生。你可以請細節? –

回答

1

變化class_name: WebGuyclass_name: AcceptanceTester

+0

是的,它做到了! Tx –

2

我有一個類似的問題與缺失wait()方法。問題是我正在使用PhpBrowser而不是WebDriver,並且PhpBrowser不提供該方法。這是微不足道的實現它自己在測試儀類:

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

最好不要做任何事情,因爲你的功能使得測試花費X秒的時間沒有理由。 – Naktibalda

+0

@Naktibalda你爲什麼確定我沒有很好的理由?例如,我可能正在等待測試郵件服務器傳送電子郵件。我可能在等待瀏覽器外發生的任何事情。 – gvlasov

+0

WebDriver中的wait()用於瀏覽器中的延遲效果。使用PhpBrowser時沒有這種效果。如果實際需要在兩個模塊中等待,最好使用不同的方法名稱。 – Naktibalda

相關問題