【selenium 3】 Mac 下測試環境搭建 Firefox 47+ gecko driver Mac


錯誤代碼如下:
File "/usr/local/lib/python2.7/dist-packages/selenium-3.0.0b2-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 65, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium-3.0.0b2-py2.7.egg/selenium/webdriver/common/service.py", line 71, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x7f753ad53390>> ignored

下載geckodriver,下不到的到我的之前的文章里有鏈接。

Windows用戶當然是加這個東西到path環境變量里,

Mac用戶看大家都遇到這個問題了,沒解決,

把這個geckodriver放在某個位置,然后

from selenium import webdriver
import time
dr = webdriver.Firefox(executable_path = '/Users/jinwenxin/desktop/pythonPractice/geckodriver')
time.sleep(5)
print 'Browser will close.'
dr.quit()
print 'Browser is close'
教大家一個方法,我用了在python下執行了help(webdriver.Firefox) 回車,這樣就知道了傳什么參數。
大家好,我就是月薪只有八千的三年測試經驗的人。
不過這只是暫時的。加油!
未來,有戲!

作者:金二哥 我就是金二哥。
鏈接:https://www.zhihu.com/question/49568096/answer/127226689
來源:知乎
著作權歸作者所有,轉載請聯系作者獲得授權。


免責聲明!

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



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