我在使用Selenium时遇到了问题.对于我的项目,我必须使用Chrome.但是,在使用Selenium启动它后,我无法连接到该浏览器.
出于某种原因,Selenium无法单独找到Chrome.当我尝试在不包含路径的情况下启动Chrome时会发生这种情况:
Traceback (most recent call last):
File "./obp_pb_get_csv.py", line 73, in <module>
browser = webdriver.Chrome() # Get local session of chrome
File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 46, in __init__
self.service.start()
File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/service.py", line 58, 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'
Run Code Online (Sandbox Code Playgroud)
为了解决这个问题,我在启动Chrome的代码中包含了Chromium路径.但是,解释器无法找到要连接的套接字:
Traceback (most recent call last):
File "./obp_pb_get_csv.py", line 73, in <module>
browser = webdriver.Chrome('/usr/bin/chromium') # Get local session of …Run Code Online (Sandbox Code Playgroud) 我正在使用selenium和python,并从我的网站下载了我的Windows计算机的chromedriver:http://chromedriver.storage.googleapis.com/index.html?path = 2.15 /
下载zip文件后,我将zip文件解压缩到我的下载文件夹.然后我将路径到可执行二进制文件(C:\ Users\michael\Downloads\chromedriver_win32)放入环境变量"路径".
但是,当我运行以下代码时:
from selenium import webdriver
driver = webdriver.Chrome()
Run Code Online (Sandbox Code Playgroud)
...我一直收到以下错误消息:
WebDriverException: Message: 'chromedriver' executable needs to be available in the path. Please look at http://docs.seleniumhq.org/download/#thirdPartyDrivers and read up at http://code.google.com/p/selenium/wiki/ChromeDriver
Run Code Online (Sandbox Code Playgroud)
但是 - 如上所述 - 可执行文件是(!)在路径中...这里发生了什么?
我使用Selenium和Python Chrome webdriver.在我使用的代码中:
driver = webdriver.Chrome(executable_path = PATH_TO_WEBDRIVER)
Run Code Online (Sandbox Code Playgroud)
将webdriver指向webdriver可执行文件.有没有办法将webdriver指向Chrome浏览器二进制文件?
在https://sites.google.com/a/chromium.org/chromedriver/capabilities中,他们有以下内容(我认为它正是我正在寻找的):
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/other/chrome/binary");
Run Code Online (Sandbox Code Playgroud)
有人有Python的例子吗?