报错信息:Traceback (most recent call last):
File "C:/Users/andy/Desktop/Python_test/baidutest.py", line 4, in
driver = webdriver.Firefox()
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 140, in __init__
self.service.start()
File "C:\Python27\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
原因:selenium3.0开始,webdriver/firefox/webdriver.py的__init__中,executable_path=geckodriver。而2.x版本是executable_path=wires。Firefox47版本以上,
解决方式:需要下载第三方插件driver,即geckodriver, 需要在http://docs.seleniumhq.org/download/的 Third Party Drivers, Bindings, and Plugins下面找到Mozilla GeckoDriver。下载并安装,安装完成后添加到Windows的path即可。