首页 > 解决方案 > chrome无头浏览器不打开网址

问题描述

我在 chrome 无头浏览器上运行我的脚本,但它没有启动 url。
铬版本:70.0,铬驱动:2.44

    System.setProperty("webdriver.chrome.driver","C:\\path\\to\\chromedriver.exe");`
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("window-size=1400,600");
WebDriver driver =  new ChromeDriver(chromeOptions);
driver.get(url);

上面的代码适用于任何其他网址,但我要启动的网址没有打开。此代码能够在 phantomjs 中启动 url,也可以在没有 headless 的情况下启动 chrome。

当试图在无头浏览器中获取页面源时,我得到了。

<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body></body></html>

任何帮助appriciated。

标签: selenium-webdriverselenium-chromedrivergoogle-chrome-headless

解决方案


推荐阅读