Home > database >  How to execute selenium scripts on an already opened browser
How to execute selenium scripts on an already opened browser

Time:05-26

The code below open a new blank window any solution? tanks!

Chrome Version 90.0.4430.72 (Official Build) (32-bit) ChromeDriver 90.0.4430.24

and tried with version Chrome version 100.0.4896.127

\command line code: C:\Program Files (x86)\Google\Chrome\Application>chrome.exe --remote-debugging-port=9222 -user-data-dir="D:\Programing\Programing App\chromedriver_win32\chromedata"

\ java code:

package selenium1;

import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions;

public class Chromeoptiontest {

public static void main(String[] args) {

    System.setProperty("webdriver.chrome.driver",
            "D:\\Programing\\Programing App\\oldChromeDriver\\chromedriver.exe");
    ChromeOptions option = new ChromeOptions();
    option.setExperimentalOption("debuggerAddress", "127.0.0.1:9222");
    ChromeDriver driver = new ChromeDriver(option);

}

}

CodePudding user response:

It's officially not supported.

However, there is some working code which claims to support this:

https://web.archive.org/web/20171214043703/http://tarunlalwani.com/post/reusing-existing-browser-session-selenium-java/.

  • Related