Selenium python 启动firefox浏览器的异常selenium.common.exceptions.WebDriverException: Message: 'geckodriver'

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH

参考:https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path

解决步骤:

1.参考以上的解决方法,依据https://github.com/mozilla/geckodriver/releases首先更新我的firefox浏览器版本,本来是53更新到55

2.下载geckodriver

3.设置执行路径:

from selenium import webdriver
driver = webdriver.Firefox(executable_path=r'your\path\geckodriver.exe')
driver.get('http://yoursite.com')

完美解决!Cheers

另附上IE,和Chrome的启动方式:

def get_chromebrowser():
    chrome_browser = webdriver.Chrome(r'yourpath\chromedriver.exe')
    return chrome_browser

def get_iebrowser():
    ie_browser = webdriver.Ie(r'C:\Program Files\Internet Explorer\IEDriverServer.exe')#这个貌似要默认的
    return ie_browser

你可能感兴趣的:(python,学习)