How to connect remotely using Python + Webdriver

I am trying to figure out how to connect to my remote web directory instance.

This is the code I'm currently using:

from selenium.remote.webdriver import WebDriver driver = WebDriver("http://172.16.205.129:4444", "firefox", "ANY") driver.get('http://google.com') driver.quit() 

I find that I can’t connect and get the connection refused, or if I play with the code, from time to time.

Any help is appreciated.

+5
source share
2 answers

You need to make sure that the selenium server hub and node are configured before the test. Please refer to this question .

Example for starting the hub

 java -jar selenium-server-standalone-2.5.0.jar -role hub 

Example node to connect to a hub, run

 java -jar selenium-server-standalone-2.5.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5555 

You can have as many nodes as you want.

+4
source

change the following line from

 driver = WebDriver("http://172.16.205.129:4444", "firefox", "ANY") 

to

 driver = WebDriver("http://172.16.205.129:4444/wd/hub", "firefox", "ANY") 

Note: "/ wd / hub" is appended to the URL in the first argument.

+2
source

All Articles