Selenium_webdriver对 chrome driver的调用
2013-03-15 15:10
369 查看
今天在使用selenium +webdriver打开chrome,代码如下:
from selenium import webdriver
driver=webdriver.Chrome()
driver.get("www.google.com")
运行代码后会出现如下错误:
Traceback (most recent call last):
File "/Selenium_Python/selenium_python/forward_url.py", line 7, in <module>
driver=webdriver.Chrome()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 60, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/service.py", line 68, in start
and read up at http://code.google.com/p/selenium/wiki/ChromeDriver")
selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path. Please download from http://code.google.com/p/selenium/downloads/list and read up at http://code.google.com/p/selenium/wiki/ChromeDriver'
提示chrome driver没有放置在正确的路径下,于是下载chrome dirver,然后放置到/usr/bin的目录下,再次运行就OK了!
这张表说明google-chrome在ubuntu 下要放置在/usr/bin的目录下
from selenium import webdriver
driver=webdriver.Chrome()
driver.get("www.google.com")
运行代码后会出现如下错误:
Traceback (most recent call last):
File "/Selenium_Python/selenium_python/forward_url.py", line 7, in <module>
driver=webdriver.Chrome()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 60, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/service.py", line 68, in start
and read up at http://code.google.com/p/selenium/wiki/ChromeDriver")
selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path. Please download from http://code.google.com/p/selenium/downloads/list and read up at http://code.google.com/p/selenium/wiki/ChromeDriver'
提示chrome driver没有放置在正确的路径下,于是下载chrome dirver,然后放置到/usr/bin的目录下,再次运行就OK了!
OS | Expected Location of Chrome |
Linux | /usr/bin/google-chrome1 |
Mac | /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome |
Windows XP | %HOMEPATH%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe |
Windows Vista | C:\Users\%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe |
相关文章推荐
- Selenium_webdriver对 chrome driver的调用
- Python模块selenium中的webdriver对Chrome的调用
- Selenium调用webdriver.chrome()出错
- selenium webdriver 打开Firefox和chrome
- pycharm运行selenium+webdriver(chromedriver)报错:unknown error: chrome failed to start
- 百度搜索_Selenium WebDriver 环境搭建和错误调试_chromedriver_win32必须下载否则无法测试chrome
- selenium 无法调用chrome driver 解决方案
- selenium webdriver 之 Chrome -headless set proxy 暨 自动化测试中无头谷歌浏览器设置代理
- Selenium WebDriver(IE,Firefox,Chrome)安装
- selenium webdriver 启动三大浏览器Firefox,Chrome,IE
- Ubuntu 16.04 selenium webdriver 启动三大浏览器Firefox,Chrome,IE
- selenium-webdriver——让chrome跑起来
- Selenium webdriver 操作chrome 浏览器
- selenium Webdriver 操作chrome浏览器
- 构建Python+Selenium2(2=WebDriver)自动化测试环境<二>:IE、Chrome和Firefox运行
- selenium 调用chrome driver 报错
- selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH
- selenium调用chromedriver打开百度网页,提示“Could not start a new session ”
- selenium webdriver调用高版本Firefox配置geckodriver
- Python脚本报错:selenium.common.exceptions.WebDriverException: Message: Service chromedriver.exe unexpect