我正在尝试使用chrome,但我需要对用户隐藏它。所以我试着在ChromeOptions中使用"headless“
ChromeOptions options = new ChromeOptions();
options.addExtensions(new File("C://temp//1.14.12_0.crx"));
options.addArguments("disable-infobars");
options.addArguments("headless");但随后我崩溃了,出现了以下异常:
[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我做了一些搜索,发现这可能与我也加载了一个广告拦截扩展的事实有关,所以我临时注释了扩展加载,并隐藏了chrome加载。但是当chrome被隐藏时,我仍然需要这个扩展为我工作。
有什么解决方案吗?
Chrome版本- 66 Chrome驱动程序版本- 2.37
谢谢!
发布于 2018-04-30 03:42:29
所以,这一条成功了:
options.addArguments("load-extension=.//resources//1.14.12_0.crx");而不是
options.addExtensions(new File(".//resources//1.14.12_0.crx"));享受吧!
https://stackoverflow.com/questions/50081093
复制相似问题