码迷,mamicode.com
首页 > 其他好文 > 详细

Selenium - 搭建环境

时间:2017-08-18 20:08:24      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:cut   space   style   rck   init   driver   执行   tab   mos   

 

 

 

 

 

1. 下载geckodriverckod

从selenium3开始,webdriver/firefox/webdriver.py的__init__中,executable_path="geckodriver";而之前是executable_path="wires"。所有需要下载geckodriver。

 

1、下载 geckodriverckod 地址: https://github.com/mozilla/geckodriver/releases

2、解压后将geckodriverckod可以存放在任意路径,在使用webdriver时指明路径就行。

例如:

将geckodriverckod放在/usr/local/bin/下,

driver = webdriver.Firefox(executable_path = "/usr/local/bin/geckodriver")

 

如果没有下载geckodriverckod或是没有指明geckodriverckod的路径,执行执行程序会报错,如下:

 

Traceback (most recent call last):

  File "/Users/evan/evan/Eclipse/Selenium/src/Selenium_learn/learn_1.py", line 14, in <module>

    driver = webdriver.Firefox()

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 144, in __init__

    self.service.start()

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 81, in start

    os.path.basename(self.path), self.start_error_message)

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

Selenium - 搭建环境

标签:cut   space   style   rck   init   driver   执行   tab   mos   

原文地址:http://www.cnblogs.com/gforc/p/7391234.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!