【发布时间】: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