在已开启Chrome窗口上调试

代码

    @Test
    void testNow() {
        /* First: Add the chrome.exe to the PATH.
         * Then: open the cmd and input the command below:
         * chrome.exe --remote-debugging-port=9222 --user-data-dir="D:\AutomationProfile"
         * You can access the url which need to test then access the address 127.0.0.1:9222 and click the url to verify.
         */
        System.setProperty("webdriver.chrome.driver", "D:\\drivers\\chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        options.setExperimentalOption("debuggerAddress", "127.0.0.1:9222");
//        options.addArguments("proxy-server=http://10.11.11.11:1234");
//        options.addArguments("disable-notifications");
//        options.addArguments("disable-popup-blocking");
//        options.addArguments("disable-extensions");
//        options.addArguments("disable-infobars");
//        options.addArguments("start-maximized");
//        options.setPageLoadStrategy(PageLoadStrategy.NONE);
        Proxy proxy = new Proxy();
        proxy.setNoProxy("www.proxy.com");
//        options.setProxy(proxy);
        WebDriver driver = new ChromeDriver(options);
        System.out.println(driver.getTitle());
        System.out.println("######################");
        System.out.println("######################");
        System.out.println("######################");
        System.out.println("######################");
    }
}

猜你喜欢

转载自www.cnblogs.com/liehen2046/p/11899376.html
今日推荐