Home » Java » Proxy support via ChromeOptions on Selenium Java-Exceptionshub

Proxy support via ChromeOptions on Selenium Java-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:
System.setProperty("webdriver.chrome.driver","C:\Users\xxxx\IdeaProjects\chromedriver.exe\");

ChromeOptions options = new ChromeOptions();

Proxy proxy = new Proxy();
proxy.setHttpProxy("107.175.153.215:3128");

options.setCapability("proxy", proxy);

ChromeDriver driver = new ChromeDriver(options);

driver.get("https://www.ipinfo.io");

I’ve been trying to figure out why this isn’t working. I’ve also tried with geckodriver, and haven’t had any success. It used to be fine a year ago, so not sure as to what’s wrong/different.

I see this being iterated in the console for a bit, and then it stops.:

[1582009560.815][SEVERE]: Timed out receiving message from renderer: 0.100

Thank you.

How to&Answers:

Seems you were close. Since Selenium v3.6.0, the ChromeOptions class in client also implements the Capabilities interface, allowing you to specify other WebDriver capabilities not specific to ChromeDriver. So may you need to:

  • Instead of using the ChromeDriver class, use the WebDriver interface.
  • Additionally, you need to remove the trailing escaped back slash i.e. \\ from the chromedriver.exe path.
  • Your effective code block will be:

    System.setProperty("webdriver.chrome.driver","C:\Users\xxxx\IdeaProjects\chromedriver.exe");
    ChromeOptions options = new ChromeOptions();
    Proxy proxy = new Proxy();
    proxy.setHttpProxy("107.175.153.215:3128");
    options.setCapability("proxy", proxy);
    ChromeDriver driver = new ChromeDriver(options);
    driver.get("https://www.ipinfo.io");