Selenium远程Webdriver错误(连接被拒绝) [英] Selenium remote webdriver error (Connection refused)

查看:618
本文介绍了Selenium远程Webdriver错误(连接被拒绝)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

from selenium import webdriver
import sys
import os
cwd = os.getcwd()
driver= webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.CHROME,command_executor='http://127.0.0.1:4444')
driver.get('http://www.google.com')

错误:

urllib.error.URLError: <urlopen error [Errno 61] Connection refused>

该程序前一阵子可以用,但是现在不行了.这就是为什么我认为这是系统错误. (OSX 10.13.4)

this program works a while ago, but now it does not. this is why I think it is a system error. (OSX 10.13.4)

推荐答案

确保已启动 Selenium独立服务器:

java -jar /path/to/selenium-server-standalone-<version>.jar 

您应该看到如下所示的输出:

You should see output which looks something like this:

Jun 06, 2018 6:47:59 PM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
18:47:59.720 INFO - Java: Oracle Corporation 24.171-b02
18:47:59.722 INFO - OS: Linux 3.13.0-149-generic amd64
18:47:59.731 INFO - v2.13.0, with Core v2.13.0. Built from revision 14793
18:47:59.889 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
18:47:59.891 INFO - Version Jetty/5.1.x
18:47:59.892 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
18:47:59.893 INFO - Started HttpContext[/selenium-server,/selenium-server]
18:47:59.893 INFO - Started HttpContext[/,/]
18:47:59.915 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@6c15f918
18:47:59.915 INFO - Started HttpContext[/wd,/wd]
18:47:59.919 INFO - Started SocketListener on 0.0.0.0:4444
18:47:59.919 INFO - Started org.openqa.jetty.jetty.Server@606145c5

注意,特别是以下内容:

Notice, in particular the line which reads:

RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub

command_executor中使用此URL:

from selenium import webdriver

driver = webdriver.Remote(
    desired_capabilities=webdriver.DesiredCapabilities.CHROME,
    command_executor='http://127.0.0.1:4444/wd/hub')
driver.get('http://www.google.com')

这篇关于Selenium远程Webdriver错误(连接被拒绝)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆