【发布时间】:2016-02-01 16:22:04
【问题描述】:
我是 Selenium 的新手,正在关注网站 http://selenium-python.readthedocs.org/
我尝试了网站上的以下代码
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
当我运行这个程序时,一个 Firefox 实例打开,但从不加载页面。 check snapshot
这是我在输出控制台中收到的
C:\Users\Gauss\Desktop>python test.py
Traceback (most recent call last):
File "test.py", line 4, in <module>
driver = webdriver.Firefox()
File "D:\Python\Python35\lib\site-packages\selenium-2.50.0-py3.5.egg\selenium\webdriver\firefox\webdriver.py", line 78, in __init__
self.binary, timeout)
File "D:\Python\Python35\lib\site-packages\selenium-2.50.0-py3.5.egg\selenium\webdriver\firefox\extension_connection.py", line 49, in __init__
self.binary.launch_browser(self.profile)
File "D:\Python\Python35\lib\site-packages\selenium-2.50.0-py3.5.egg\selenium\webdriver\firefox\firefox_binary.py", line 68, in launch_browser
self._wait_until_connectable()
File "D:\Python\Python35\lib\site-packages\selenium-2.50.0-py3.5.egg\selenium\webdriver\firefox\firefox_binary.py", line 106, in _wait_until_connectable
% (self.profile.path))
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: C:\Users\Gauss\AppData\Local\Temp\tmpkpjhnhpb If you specified a log_file in the FirefoxBinary constructor, check it for details.
有人可以建议解决这个问题吗?
注意:这个问题出现在我的办公室电脑上,同样的代码在我的家用电脑上也能正常工作。所以可能是 Firefox 的一些问题。
【问题讨论】:
-
这篇文章提到该问题已在 2.26 版后得到修复,但我使用 2.50 仍面临此问题,我正在使用 Windows 10 并且 Firefox 版本为 44.0
标签: python firefox selenium selenium-webdriver