Selenium没有打开网页

时间:2015-06-28 02:09:36

标签: python macos selenium

当我运行以下代码时,我得到一个我不理解的错误,我认为它与我在计算机上设置selenium的方式有关。 (我在Mac OS上是否相关)

from selenium import webdriver

driver = webdriver.Firefox()
driver.get('https://www.google.com')
driver.close()

当我尝试运行该程序时出现以下错误:

File "win.py", line 3, in <module> 
    driver = webdriver.Firefox()
File "/Users/shazam/Library/Python/2.7/lib/python/site-packages/selenium/webdriver/firefox/webdriver.py", line 64, in __init__
    self.binary, timeout),
File "/Users/shazam/Library/Python/2.7/lib/python/site-packages/selenium/webdriver/firefox/extension_connection.py", line 51, in __init__ 
    self.binary.launch_browser(self.profile)
File "/Users/shazam/Library/Python/2.7/lib/python/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 69, in launch_browser 
    self._start_from_profile_path(self.profile.path)
File "/Users/shazam/Library/Python/2.7/lib/python/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 92, in _start_from_profile_path 
    env=self._firefox_env)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 709, in __init__ 
    errread, errwrite) 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1326, in _execute_child
    raise child_exception

1 个答案:

答案 0 :(得分:0)

此错误,是因为我的计算机上未安装Firefox。对我来说应该是显而易见的,但事实并非如此。