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

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 中执行

Str*_*lfa 5

IE 不支持无头模式(因为现在 IE 没有收到任何类型的更新或改进。)。

但是你可以使用trifle.js,一种可以在无头模式下模拟某些 IE 版本的浏览器,因为它被编码为 PhantomJS 的端口。