selenium.common.exceptions.WebDriverException: Message: Failed to start browser:搞哭了


  最近在研究基於python的selenium自動化,結果一開始就死在了環境搭建上,前前后后整了N天,終於搞出來了,像中獎了

  按部就班的參照網上安裝步驟,安裝完成后,寫了個簡單的自動化腳本  #-*- coding: utf-8 -*-

  from selenium import webdriver
  from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

  browser = webdriver.Firefox()
  browser.get("http://www.baidu.com")
  browser.find_element_by_id("kw").send_keys("selenium")
  browser.find_element_by_id("su").click()
  browser.quit()

  程序一跑,中獎報錯了:selenium.common.exceptions.WebDriverException: Message: Failed to start browser:省略不計了
  百度一下吧,搜索結果大致是說selenium和火狐的版本不兼容導致,索性重新搞吧:
  1、selenium版本:selenium-2.45.0
  2、火狐瀏覽器版本:36.0
重新再跑下程序,OK搞定了,一塊心病終於治好了

話外題:我機器火狐未安裝到默認路徑,結果運行還是會報錯:

      后來在代碼中添加一句:

                 from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

    搞定!!!


 
        
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM