【发布时间】:2017-10-09 22:52:45
【问题描述】:
我想为所有 3 种浏览器 Chrome、Firefox 和 IE 以 Headless 模式运行脚本
以下是Chrome的代码:
System.setProperty("webdriver.chrome.driver", "./drive/chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("headless");
options.addArguments("window-size=1400,600");
WebDriver driver = new ChromeDriver(options);
driver.get("http://www.google.com/");
注意:它工作正常
火狐:
FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.addCommandLineOptions("--headless");
System.setProperty("webdriver.gecko.driver", "./drive/geckodriver.exe");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setBinary(firefoxBinary);
FirefoxDriver driver = new FirefoxDriver(firefoxOptions);
driver.get("http://www.google.com/");
注意:它工作正常
IE:
同样我想用选项在 IE 中执行
【问题讨论】:
标签: selenium selenium-webdriver