2015-04-15 187 views
3

我想在Selenium IDE中運行記錄的測試用例。問題是,當我嘗試執行整個測試用例時,Selenium會阻止它在頁面上找不到元素。問題是我可以執行測試用例的單個步驟。我認爲Selenium在加載新頁面之前試圖找到一個元素,所以我使用了clickAndWait,暫停和waitForElementPresent命令 - 沒有任何工作,Selenium停止測試用例。Selenium IDE找不到元素

調試日誌

• [info] Executing: |`clickAndWait` | css=i.fa.fa-arrow-left | | 
• [debug] Command found, going to execute clickAndWait 
• [debug] modifyWindow seleniumMarker1429084950752:selenium1429084951105 
• [debug] _getFrameElement: frameElement=null 
• [debug] modifySeparateTestWindowToDetectPageLoads: already polling this window: selenium1429084951105 
• [debug] getCurrentWindow newPageLoaded = false 
• [error] Element css=i.fa.fa-arrow-left not found 
• [debug] commandError 
• [debug] testComplete: failed=true 
• [info] Test case failed 

我將是任何幫助和建議,非常感謝。

+0

需要更多信息在這裏。看到更多的腳本將有所幫助。在css = i.fa.fa-arrow-left上執行clickAndWait之前會發生什麼?您是否檢查過在clickAndWait之前是否存在該元素。這似乎是這裏所暗示的。 – DMart

+0

也有這個測試涉及多個窗口? – DMart

回答

1

在某些情況下,'ClickAndWait'不可靠,並且不會等待命令完成,然後才能轉到下一個命令。在這種情況下,替代方法是使用「點擊」,然後使用「waitForPageToLoad」進行跟蹤。

例...

ORIGINAL

<tr> 
    <td>clickAndWait</td> 
    <td>//input[@type='submit']</td> 
    <td></td> 
</tr> 

<tr> 
    <td>click</td> 
    <td>//input[@type='submit']</td> 
    <td></td> 
</tr> 
<tr> 
    <td>waitForPageToLoad</td> 
    <td>10000</td> 
    <td></td> 
</tr> 

如果這沒有幫助,請發表你的源代碼,我會看看有沒有別的東西,我可以建議。

+0

這是多餘的。 ClickAndWait可以做到這一點。然而,AndWait可以在DOM準備好的情況下觸發,如果還有javascript和/或ajax,可能沒有加載所有元素。 – DMart

+1

嗨@DMart。我看到AndWait在其他一些情況下也失敗了 - 特別是在域名被設置爲轉發到IP而不是綁定到IP的情況下。在這種情況下,頁面上沒有JavaScript或AJAX,我的腳本也沒有等待。但是,當我將操作分成Click和WaitForPageToLoad時,它確實成功地等待了。在這個特定的情況下,它不是多餘的。 –

+0

它由文檔['readyState']確定,具體爲!! document ['readyState']。 https://github.com/SeleniumHQ/selenium/blob/6b4e6de722fcccd18619951543143999e9a30657/java/client/src/com/thoughtworks/selenium/webdriven/commands/WaitForPageToLoad.java 更多的readyState:HTTP://www.w3schools。 COM/jsref/prop_doc_readystate.asp – DMart

相關問題