【发布时间】:2017-07-05 02:16:11
【问题描述】:
问题
我正在关注文档here 中列出的示例。基本上,只是试图让 Selenium 打开 Firefox,带我到一个站点,进行查询,然后关闭浏览器。
我遇到了一个问题,Selenium 会打开浏览器,但不会转到指定的网站。在其他情况下,我收到一个错误,我应该提到这个错误仅在升级 Selenium 后出现。
Traceback (most recent call last):
File "script.py", line 4, in <module>
browser = webdriver.Firefox()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 142, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
- 我正在使用最新版本的 Firefox,
54.0.1 - 我正在使用 Python 版本
2.7.11 - 我有 Selenium 版本
3.4.3
script.py
>from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser = webdriver.Firefox()
browser.get('http://www.yahoo.com')
assert 'Yahoo!' in browser.title
elem = browser.find_element_by_name('p') # Find the search box
elem.send_keys('seleniumhq' + Keys.RETURN)
browser.quit()
【问题讨论】:
-
你下载geckodriver并设置它的路径。谷歌一下,你会发现很多帖子。
标签: python selenium firefox selenium-webdriver webdriver