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? Commented Apr 2, 2021 at 14:53

1 Answer 1

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") Commented Apr 2, 2021 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.