當我使用SeleniumRC時,有時會遇到錯誤,但有時不會。我想這與wait_for_page_to_load()
的時間有關,但我不知道需要多長時間?30000ms後超時
錯誤信息:
Exception: Timed out after 30000ms
File "C:\Users\Herta\Desktop\test\newtest.py", line 9, in <module>
sel.open(url)
File "C:\Users\Herta\Desktop\test\selenium.py", line 764, in open
self.do_command("open", [url,])
File "C:\Users\Herta\Desktop\test\selenium.py", line 215, in do_command
raise Exception, data
這是我的計劃:
from selenium import selenium
url = 'http://receptome.stanford.edu/hpmr/SearchDB/getGenePage.asp?Param=4502931&ProtId=1&ProtType=Receptor#'
sel = selenium('localhost', 4444, '*firefox', url)
sel.start()
sel.open(url)
sel.wait_for_page_to_load(1000)
f = sel.get_html_source()
sav = open('test.html','w')
sav.write(f)
sav.close()
sel.stop()
您能正常訪問Firefox中的URL嗎? – katrielalex 2010-08-11 13:48:26
是的,它的工作原理。 如果我逐個運行腳本,(這意味着sel.open(url)完成了。),它工作正常。但我不知道完成開放步驟需要多長時間。所以sel.wait_for_page_to_load(1000)有些問題。但我不知道如何弄清楚。 – Herta 2010-08-11 14:01:23