4
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')

error:

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

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)

2 Answers 2

3

Make sure you've started the Selenium Standalone Server:

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

Use this URL in command_executor:

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')
Sign up to request clarification or add additional context in comments.

Comments

0

As per the API Docs the Remote WebDriver implementation is as follows:

class selenium.webdriver.remote.webdriver.WebDriver(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=False, file_detector=None, options=None)

An example:

# Instantiate an instance of Remote WebDriver with the desired capabilities.
driver = webdriver.Remote(desired_capabilities=capabilities, command_executor=selenium_grid_url)    

So you need to change the line of code from:

driver= webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.CHROME,command_executor='http://127.0.0.1:4444')

To:

driver= webdriver.Remote(desired_capabilities=DesiredCapabilities().CHROME,command_executor='http://127.0.0.1:4444')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.