【问题标题】:How to Set capability for IE browser to run in Headless mode如何设置 IE 浏览器在 Headless 模式下运行的能力
【发布时间】: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


    【解决方案1】:

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

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

    【讨论】:

    • 我找不到任何关于 trifle.js 的示例。如何将 trifle.js 添加到我的 c# 代码中
    • @UglukFromIsengard 使用 phantonJs api 运行。所以你需要下载它的 .exe 文件并加载并使用它作为 phantonJs 驱动程序,你会在网络上找到大量的例子。
    • 我下载了 TripleJS,它只是一个 .exe 文件。我试图在 C# 代码中提供 phantonJs 驱动程序。它不接受它。当我运行我的代码时,它仍在寻找 phantomJs.exe。我不知道如何将 TripleJS 用作 phantonJs 驱动程序。你能和我分享一个例子吗?顺便说一句,我正在尝试将 TripleJS 实现为 C# 中的 selenium webdriver。
    猜你喜欢
    • 2013-02-23
    • 1970-01-01
    • 1970-01-01
    • 2014-12-19
    • 1970-01-01
    • 1970-01-01
    • 2011-12-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多