How to use / attach an existing browser using Selenium?

What is the Selenium equivalent to join an existing browser in Watir?

brw = Watir::IE.attach(:title, "Google") 
+7
selenium-webdriver browser-automation
source share
2 answers

This is a duplicate of the answer ** Connect to a driver in python selenium ** This applies to all drivers. 1. open the driver

 driver = webdriver.Firefox() 

2. Extract into session_id and _url from the driver object.

 url = driver.command_executor._url #"http://127.0.0.1:60622/hub" session_id = driver.session_id #'4e167f26-dc1d-4f51-a207-f761eaf73c31' 

3. Use these two options to connect to your driver.

 driver = webdriver.Remote(command_executor=url,desired_capabilities={}) driver.session_id = session_id 

And you are again connected to your driver.

 driver.get("http://www.mrsmart.in") 
+4
source share
  • Run Webdriver First

    driver = new FirefoxDriver ();

  • Now run RemoteWebdriver

    Features DesiredCapabilities = DesiredCapabilities.firefox ();
    driver = new RemoteWebDriver (new URL (" http: // localhost: 7055 / hub ", features);

RemoteWebdriver will attach to the first browser window on which Webdriver is running, and it will not create a new window.


Note. Run Webdriver (1) and RemoteWebdriver (2) in separate programs one at a time).

+3
source share

All Articles