如何在已经打开的浏览器上执行 selenium 脚本

How to execute selenium scripts on an already opened browser

下面的代码开一个新的空白window 任何解决方案? 坦克!

Chrome 版本 90.0.4430.72(正式版)(32 位) Chrome驱动程序 90.0.4430.24

并尝试使用版本 Chrome 版本 100.0.4896.127

\命令行代码: C:\Program Files (x86)\Google\Chrome\Application>chrome.exe --remote-debugging-port=9222 -user-data-dir="D:\Programing\Programing App\chromedriver_win32\chromedata" =11=]

\java代码:

包 selenium1;

进口org.openqa.selenium.chrome.ChromeDriver; 导入 org.openqa.selenium.chrome.ChromeOptions;

publicclassChrome选项测试{

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);

}

}

官方不支持

但是,有一些工作代码声称支持这个:

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