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

1
  • 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 Apr 2 at 14:53
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

1
  • eg: proxy.setSocksProxy("127.0.0.1:5555") – PDHide Apr 2 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.