硒无头铬碎片崩溃,而头部镀铬则可以很好地工作



我有一个geb脚本访问 http://google.com并打印标题,该标题与"正常"/headed Google Chrome及其驱动程序(Windows 32-PIT版本2.35(完美愉快。但是,当我将ChromeOptions.headless字段设置为true时,测试将冻结。到达页面非常慢,并且在驱动程序完成到页面上后,脚本崩溃了,消息是导航器为空的消息。因此,这里显然出了问题。我正在使用 Geb 2.1selenium-support-2.52.0 -jar。

你们知道发生了什么事吗?

最好的问候

我几次遇到了同样的问题,我能够使用以下代码创建和使用无头Chrome driver实例:

System.setProperty("webdriver.chrome.driver", webDriverExec)
ChromeOptions chromeOptions = new ChromeOptions()
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("window-size=1200,1100")
driver = new ChromeDriver(chromeOptions)

通过使用此代码并设置窗口大小,我能够解决与空导航器有关的问题。

相关内容

最新更新