2

I have been trying to resolve a few issues with RemoteWebDriver and ChromeOptions using docker and selenium grid. The main issue is with the proxy but I half resolved that with a proxy pac file passing the pac file url as an arg into ChromeOptions. The below code runs great in docker debug and standalone locally but as soon as I try with the grid or deploy and run with bamboo the driver opens and I can see that ChromeOptions are not being passed because the poxy pac file is not being used and it's just frozen at org.openqa.selenium.remote.ProtocolHandshake createSession. I have been researching for a few weeks now and I am at a hard blocker with this now. I have seen some posts that DesiredCapabilities is deprecated but I have not found a way to implement ChromeOptions without it.

    ChromeOptions options = new ChromeOptions();
    options.addArguments("--start-maximized");
    options.addArguments("--disable-infobars");
    options.addArguments("--proxy-pac-url= http://ProxyPacURL.com");
    DesiredCapabilities dc = DesiredCapabilities.chrome();
    dc.setCapability(ChromeOptions.CAPABILITY, options);
    driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), dc);
titan9873
  • 41
  • 3

3 Answers3

2

Update to latest Selenium Jars, make sure your java is version 1.8 or greater, then you can pass ChromeOptions into the driver because DesiredCapabilities is deprecated. I am now able to run selenium docker nodes with selenium grid and all ChromeOptions arguments are now being passed to the containers.

    ChromeOptions options = new ChromeOptions();
    options.addArguments("--start-maximized");
    options.addArguments("--disable-infobars");
    options.addArguments("--proxy-pac-url=http://myPacFile.com");
    options.addArguments("--no-sandbox");
    driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), options);
titan9873
  • 41
  • 3
  • I am having the same difficulty described above. I am using java 1.8, selenium-server-standalone-3.141.59.jar, with chrome 76.x and the chromedriver for chrome 76. I am using exact syntax above. The options ("--start-maximiaxed", setting logfile location etc) do not get passed to the remote web driver. Did you have to make any other adjustments?? – JackhammersForWeeks Aug 13 '19 at 15:35
0

Try this:

const GRID_HOST = 'http://localhost:4444/wd/hub';

var options = new chrome.Options();
options.addArguments("--start-maximized");
options.addArguments("--disable-infobars");
options.addArguments("--proxy-pac-url=http://myPacFile.com");
options.addArguments("--no-sandbox");

driver = new webdriver.Builder()
.usingServer(GRID_HOST)
.forBrowser("chrome")
.setChromeOptions(options)
.build()
Tomás
  • 1
0

I was facing same issue and I have found the solution as below: We need to set "goog:chromeOptions" instead of "chromeOptions".

In your Java code, following line is present:

dc.setCapability(ChromeOptions.CAPABILITY, options);

If you navigate to ChromeOptions.CAPABILITY, you will notice that it is a constant with value "chromeOptions". This works fine for local web driver, but not for remote web driver (i.e. selenium grid).

Just change above line to this:

dc.setCapability("goog:chromeOptions", options);

Now when you execute your Java code, it will work fine and all your options will show their effect too.

I came across other pages, such as this, which referred to above solution.

Vaibhav Shah
  • 83
  • 1
  • 8