之前用的Selenium2,总是要找低版本的火狐才能使用
最近升级到了Selenium3后,和最新的firefox49就能匹配使用,不过也碰到了一些问题
1. 要先将geckodriver.exe放到firefox的安装目录下,我这里的路径为C:\Program Files (x86)\Mozilla Firefox
2. python脚本:
from selenium import webdriver
driver=webdriver.Firefox(executable_path = 'C:\\Program Files (x86)\\Mozilla Firefox\\geckodriver.exe')
driver.get("https://www.baidu.com")
3.如果运行上述脚本报错:Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
请尝试:
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe')
driver=webdriver.Firefox(executable_path='C:\\ProgramFiles(x86)\\MozillaFirefox\\geckodriver.exe',firefox_binary=binary)