Vij*_*jay 9 selenium selenium-webdriver
我想在无头模式下为所有 3 种浏览器 Chrome、Firefox 和 IE 运行脚本
以下是 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/");
Run Code Online (Sandbox Code Playgroud)
注意:它工作正常
火狐:
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/");
Run Code Online (Sandbox Code Playgroud)
注意:它工作正常
IE:
同样,我想在带有选项的 IE 中执行
| 归档时间: |
|
| 查看次数: |
19721 次 |
| 最近记录: |