1
votes

I am trying to use chrome but I need it to be hidden from the user. So I tried to use "headless" with ChromeOptions

    ChromeOptions options = new ChromeOptions();
    options.addExtensions(new File("C://temp//1.14.12_0.crx"));
    options.addArguments("disable-infobars");
    options.addArguments("headless");

but then I crashed with the following exception:

[1524948093.974][WARNING]: chrome quit unexpectedly, leaving behind temporary directories for debugging:
[1524948093.974][SEVERE]: Port leaked: 12545
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: failed to wait for extension background page to load: chrome-extension://cjpalhdlnbpafiamejdnhcphjbkeiagm/background.html
from unknown error: page could not be found: chrome-extension://cjpalhdlnbpafiamejdnhcphjbkeiagm/background.html
  (Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 10.0.16299 x86_6

I made some searching and found out that it might be related to the fact that I also load an ad blocker extension, so I temporarily commented the extension loading and the chrome was loaded HIDDEN. But I still need this extension to work for me when chrome is hidden.

Is there any solution?

Chrome Version - 66 Chrome Driver version - 2.37

Thanks!

1

1 Answers

2
votes

So, this one made the trick:

options.addArguments("load-extension=.//resources//1.14.12_0.crx");

instead of

options.addExtensions(new File(".//resources//1.14.12_0.crx"));

Enjoy!