【问题标题】:Is there any Headless browser that supported by selenium with Downloading feature enabled是否有任何支持 Selenium 并启用下载功能的 Headless 浏览器
【发布时间】:2016-12-03 23:56:36
【问题描述】:

我想使用 selenium 按下几个按钮来为我的测试过程下载文件。这个网页使用了 Javascript,所以不可能使用 HttpState 之类的东西来连接 Http 客户端。我发现 PhantomJs 不支持这个功能(Linux 上的 Esspessialy)。我在 Firefox 中使用以下代码,但它不是无头的。

 FirefoxProfile fprofile = new FirefoxProfile();
    String path;
    if (SystemUtils.IS_OS_LINUX) {
        path = "/tmp/hon/";
    } else {
        path = "c:\\Downloads\\hon\\";
    }
    fprofile.setPreference("browser.download.dir", path);
    fprofile.setPreference("browser.download.folderList", 2);
    fprofile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application / zip");             fprofile.setPreference("browser.download.manager.showWhenStarting", false);
    fprofile.setPreference("pdfjs.disabled", true);
    mDriver = new FirefoxDriver(fprofile);

有什么解决方案可以在一些无头浏览器上使用这样的结构吗?

【问题讨论】:

    标签: java selenium headless-browser


    【解决方案1】:

    你可以试试XVFBX11显示服务器。它在无头模式下工作,就像一个真实的显示器,你可以截屏和其他东西。

    【讨论】:

    • 我不能使用这种方式,原因有几个。至少我需要这个解决方案跨平台。我正在寻找无头浏览器,而不是显示服务器。
    猜你喜欢
    • 2012-05-22
    • 2012-12-12
    • 1970-01-01
    • 2011-11-26
    • 2012-07-20
    • 1970-01-01
    • 2022-07-26
    • 1970-01-01
    • 2018-06-03
    相关资源
    最近更新 更多