2011-11-05 65 views
0

我使用硒與Python腳本,我試圖用wait_for_condition功能。硒阿賈克斯wait_for_condition

我想等待通過此XPath定義的元素:

"/html/body/form/div[3]/div/div/div[2]/div/div/div/table/tbody/tr[8]/td[2]" 

在場,所以我嘗試以下:

sel.wait_for_condition(
    "var x = selenium.browserbot.findElementOrNull('/html/body/form/div[3]/div/div/div[2]/div/div/div/table/tbody/tr[8]/td[2]'); x != null && x.style.display == 'none';", "5000"); 

但它不工作,能不能有人告訴我有什麼不對嗎?

非常感謝你,

問候

回答

0

超時,5000,應該給出一個整數,而不是字符串:

sel.wait_for_condition(
    "var x = selenium.browserbot.findElementOrNull('/html/body/form/div[3]/div/div/div[2]/div/div/div/table/tbody/tr[8]/td[2]'); x != null && x.style.display == 'none';", 
    5000) 
從文檔

另外:

Note that, by default, the snippet will be run in the runner's test window, not in the window 
    of your application. To get the window of your application, you can use 
    the JavaScript snippet ``selenium.browserbot.getCurrentWindow()``, and then 
    run your JavaScript in there. 
+0

我試過THI你給了我一個,但我仍然有同樣的問題。我相信xpath表達式 也許別的地方有什麼錯? –