WebDriverException: Message: #39;Can not connect to the ChromeDriver#39;. Error in utils.is_connectable(self.port):(WebDriverException:消息:“无法连接到 ChromeDriver.utils.is_connectable(self.port) 中的错误:)
问题描述
我正在尝试使用 chromedriver 2.10 在 CentOS 机器上的 Chrome 浏览器版本 35.0.1916.114 上运行测试
/home/varunm/EC_WTF_0.4.10/EC_WTF0.4.10_Project/wtframework/wtf/drivers/chromedriver
/home/varunm/EC_WTF_0.4.10/EC_WTF0.4.10_Project/wtframework/wtf/drivers/chromedriver
实际上我修复了路径问题,因为如果问题与路径有关,则错误消息会有所不同
Actually I fixed the path issue, because the error message was different if the issue was with path
def start(self):
"""
Starts the ChromeDriver Service.
:Exceptions:
- WebDriverException : Raised either when it can't start the service
or when it can't connect to the service
"""
env = self.env or os.environ
try:
self.process = subprocess.Popen([
self.path,
"--port=%d" % self.port] +
self.service_args, env=env, stdout=PIPE, stderr=PIPE)
except:
raise WebDriverException(
"ChromeDriver executable needs to be available in the path.
Please download from http://chromedriver.storage.googleapis.com/index.html
and read up at http://code.google.com/p/selenium/wiki/ChromeDriver")
count = 0
while not utils.is_connectable(self.port):
count += 1
time.sleep(1)
if count == 30:
raise WebDriverException("Can not connect to the ChromeDriver")
如果路径错误,我会收到一些其他错误,但现在错误是在建立连接时
If the path was wrong I will receive some other error, but now the error is while making the connection
推荐答案
适用于 Linux
1.检查你是否安装了最新版本的chrome brwoser-> "chromium-browser -version"
2.如果没有,安装最新版本的chrome sudo apt-get install chromium-browser"
3. 从以下链接获取适当版本的 chrome 驱动程序 http://chromedriver.storage.googleapis.com/index.html一个>
4.解压chromedriver.zip
5.将文件移动到/usr/bin/目录sudo mv chromedriver/usr/bin/
6. 转到/usr/bin/目录,你需要运行类似chmod a+x chromedriver"的东西来标记它可执行.
7.终于可以执行代码了.
For Linux
1. Check you have installed latest version of chrome brwoser-> "chromium-browser -version"
2. If not, install latest version of chrome "sudo apt-get install chromium-browser"
3. get appropriate version of chrome driver from following link http://chromedriver.storage.googleapis.com/index.html
4. Unzip the chromedriver.zip
5. Move the file to /usr/bin/ directory sudo mv chromedriver /usr/bin/
6. Goto /usr/bin/ directory and you would need to run something like "chmod a+x chromedriver" to mark it executable.
7. finally you can execute the code.
import os
from selenium import webdriver
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()
driver = webdriver.Chrome()
driver.get("http://www.google.com")
print driver.page_source.encode('utf-8')
driver.quit()
display.stop()
这篇关于WebDriverException:消息:“无法连接到 ChromeDriver".utils.is_connectable(self.port) 中的错误:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:WebDriverException:消息:“无法连接到 ChromeDriver".utils.is_connectable(self.port) 中的错误:
基础教程推荐
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 筛选NumPy数组 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01