I have tried both the below code but unable to set proxy
Proxy proxy = new Proxy();
proxy.setHttpProxy("socks5://localhost:8080");
ChromeOptions options = new ChromeOptions();
options.addArguments("--proxy-server= proxy");
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.get("url");
or ChromeOptions chromeOption= new ChromeOptions(); WebDriverManager.chromedriver().proxy("socks5://localhost:8080").setup(); WebDriver driver=new ChromeDriver(chromeOption); driver.get("url");
-
Welcome. It's helpful to provide as much detail in your question as possible to get a good answer. Can you add the error messages you get when you use this code? What makes it unsuccessful?Lee Jensen– Lee Jensen2021年04月02日 14:53:40 +00:00Commented Apr 2, 2021 at 14:53
1 Answer 1
ChromeOptions chromeOptions = new ChromeOptions();
String proxyadd = "176.9.119.170:8080";
Proxy proxy = new Proxy();
proxy.setHttpProxy(proxyadd);
proxy.setSslProxy(proxyadd);
chromeOptions.setCapability("proxy", proxy);
WebDriver driver = new ChromeDriver(chromeOptions);
There is a proxy class that can be used to set proxy including sock
https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/Proxy.html
answered Apr 2, 2021 at 15:33
-
eg: proxy.setSocksProxy("127.0.0.1:5555")PDHide– PDHide2021年04月02日 21:05:12 +00:00Commented Apr 2, 2021 at 21:05
default