python - Selenium WebDriver (2.25) 超时不工作

标签 python selenium selenium-webdriver

我想我已经阅读了 Stack Overflow 上所有关于 Selenium 超时的问题,但是隐式或显式超时在我的 Selenium webdriver 2.25(Python 2.7 绑定(bind))中都不起作用,而且“no_timeout_here ="两行都将永远挂起 --

browser = webdriver.Firefox()
browser.implicitly_wait(6)               
browser.set_page_load_timeout(30)        
browser.get("http://www.google.com")
try:
    #no_timeout_here = browser.find_element_by_id("id_not_found")
    no_timeout_here = WebDriverWait(browser, 5).until(lambda browser:
            browser.find_element_by_id("id_not_found"))
except:
    raise

将不胜感激所有指点!

10 月 16 日更新

感谢 seleniumnewbie 的全面回答,但是,您的单元测试代码仍然卡在我的 Python 2.7 下的 Ubuntu 11.04(64 位)上 --

(2012/10/17 11:51:58)$ time ./timeout.py 
^CTraceback (most recent call last):
...
KeyboardInterrupt

real    2m26.572s
user    0m0.368s
sys 0m0.232s

(2012/10/17 11:54:26)$ python -V
Python 2.7.2+

(2012/10/17 11:57:04)$ uname -a
Linux 3.0.0-26-generic #43-Ubuntu SMP Tue Sep 25 17:19:22 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

(2012/10/17 11:57:10)$ ls selenium-server-standalone-2.25.0.jar

我可以知道您的操作系统/Python 版本吗?

最佳答案

如果您使用的是 Firefox 17 和 Selenium 2.26.0,那么您遇到了缺陷 #4814:http://code.google.com/p/selenium/issues/detail?id=4814

关于python - Selenium WebDriver (2.25) 超时不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12880024/

相关文章:

python - Travis CI 默认使用错误的语言

python - 从非空 defaultdict 中选取一个随机元素

java - Chrome 不会自动打开 URL

python - 无法在 http ://www. dropzonejs.com 上使用 python selenium webdriver 上传文件

node.js - 如何使用 WebdriverIO 获取窗口变量

python - 如何将 Nonetype 放入列表中?

python - 在 numpy 中组合两个数组,

java - 如何在另一个 html 标签内选择带有 html 源的 web 元素 selenium web 驱动程序

javascript - 使用 Python 等待 Selenium 中所有资源加载

html - 如何从样式元素中获取值?