How to set proxy for Chrome browser in selenium using Java code

后端 未结 5 1303
误落风尘
误落风尘 2021-02-08 15:08

I am trying to run my selenium java code to test a webpage. But webpage is not loading because of network restrictions. When I set the proxy manually and hit the url in browser

5条回答
  •  遥遥无期
    2021-02-08 15:33

    Passing a Capabilities object to the ChromeDriver() constructor is deprecated. One way to use a proxy is this:

    String proxy = "127.0.0.1:5000";
    ChromeOptions options = new ChromeOptions().addArguments("--proxy-server=http://" + proxy);
    WebDriver webDriver = new ChromeDriver(options);
    

提交回复
热议问题