如何设置IE浏览器在无头模式下运行的功能 [英] How to Set capability for IE browser to run in Headless mode

查看:705
本文介绍了如何设置IE浏览器在无头模式下运行的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在无头模式下为所有3种浏览器运行脚本,例如Chrome,Firefox和Amp; IE浏览器

I want to run the scripts in Headless mode for all the 3 browsers Chrome, Firefox & IE

以下是Chrome的代码:

The following is the code for 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/");

注意:可以正常工作

Firefox:

    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中使用选项执行

Similarly i want to execute in IE with options

推荐答案

IE不支持无头模式(因为如今的IE尚未接受任何形式的更新或改进.).

IE does not have support for a headless mode (since IE nowadays does not recieve any kind of update or improvements.).

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

But you can use trifle.js, a kind of browser that can emulate some IE versions in a headless mode, since its coded as a port of PhantomJS.

这篇关于如何设置IE浏览器在无头模式下运行的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆