小编Vij*_*jay的帖子

如何设置 IE 浏览器在 Headless 模式下运行的能力

我想在无头模式下为所有 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 中执行

selenium selenium-webdriver

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

selenium ×1

selenium-webdriver ×1