2016-07-01 81 views
0

我有失敗的codeception測試奇怪的問題。Codeception測試隨機使用點擊重定向失敗

有時點擊鏈接/按鈕上使用的方法不會重定向到頁面。 有時它確實,但是配置文件無法識別它(我在輸出中看到重定向工作的圖像)。 有時它完全可以,測試運行在100%。

我在jenkins上使用了phantomjs 2.1.1的codeception 2.2.1版本。

一個問題測試:

$I->wantTo('verify that recent comments module are correctly presented'); 
$I->amOnPage('/pl/'); 
$I->click('.cookie-policy-info__btn-close'); 
$I->see('Najciekawsze opinie', '.section-title-bar'); 
$I->seeElement('.hp-recent-opinions.one-column-product-wrapper'); 
$I->seeElement('ul.slides:nth-child(1) > li > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > a:nth- 
$I->click('ul.slides:nth-child(1) > li > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > a:nth-child 
$I->seeInCurrentUrl('/audiobook/'); 
$I->moveBack(1); 
$I->click('ul.slides:nth-child(1) > li > div.product-tile > div.product-tile__desc > div.product-tile__author 
$I->seeInCurrentUrl('/search/author?'); 
$I->moveBack(1); 

$this->titleCss() = 'ul.slides:nth-child(1) > li > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > a:nth-child(1)'

和codeception輸出的例子:

5) ContentModulesCest: Verify that recent comments module are correctly presented 
Test tests/acceptance/ContentModulesCest.php:recentCommentsModule 
Step See in current url "/foobar/" 
Fail Failed asserting that '/pl/' contains "/foobar/". 

Scenario Steps: 

8. $I->seeInCurrentUrl("/foobar/") 
7. $I->click("ul.slides:nth-child(1) > li > div:n...") 
6. $I->seeElement("ul.slides:nth-child(1) > li > div:n...") 
5. $I->seeElement(".hp-recent-opinions.one-column-prod...") 
4. $I->see("Najciekawsze opinie",".section-title-bar") 

,並對圖像我看到該頁面。有點奇怪。 任何想法如何阻止隨機失敗?

+0

您的輸出與您的測試不匹配,您的測試中沒有seeInCurrentUrl和seeElement。 – Naktibalda

+0

您還錯過了上述步驟中錯誤輸出的重要部分。 – Naktibalda

+0

@Naktibalda是的,我的錯誤。就在星期五 –

回答

2

可能當Codeception嘗試點擊時,該元素是不可見的(尚未加載)。嘗試在click方法之前使用waitForElementVisible方法。

此外它可以連接PhantomJS版本。我有很多奇怪的問題 - 一切皆有可能。