2016-01-07 111 views
0

運行測試用例時出現問題,因爲加載頁面的時間每次都不相同。我嘗試過WaitforPageLoad,同時也檢查可視元素,但沒有幫助。如何等待頁面在Selenium IDE中加載而不是waitforpageload?

WaitforPageLoad總是等待特定的秒數,並且檢查視覺元素不會一直工作,因爲在加載頁面後,在某些頁面中不會有任何新元素。

任何人都可以提出一個更好的主意嗎?

+0

你能看到http://stackoverflow.com/questions/6568081/selenium-how-to-wait-for-options-in-a-select-to-be-populated它是否解決您的查詢? –

+0

你如何啓動頁面加載?點擊? – DMart

+0

/你的頁面加載的想法是什麼? Selenium認爲它是Dom準備好的狀態。你能提供更多細節嗎? – DMart

回答

0

你可以增加你的時間等待頁面加載量:

的setTimeout(超時) 參數:

timeout - a timeout in milliseconds, after which the action will return with an error 

Specifies the amount of time that Selenium will wait for actions to complete. 

Actions that require waiting include "open" and the "waitFor*" actions. 
The default timeout is 30 seconds. 

這可能會有幫助。這有點不清楚你的目標是什麼。

0

在您的操作中使用顯式等待。例如:

  // Tell webdriver to wait 
      WebDriverWait wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(4)); 

      // Test the autocomplete response - Explicit Wait 
      IWebElement autocomplete = wait.Until(x => x.FindElement(By.ClassName("ac-row-110457"))); 
相關問題