本文介绍了如何设置InternetExplorerDriver下载目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用Selenium从我们的Web应用程序测试文件下载。目前我们正在使用Firefox,将其设置为所需的下载目录,并确保没有弹出对话框,下载文件时不需要用户交互。

We use Selenium to test file downloads from our web application. Currently we are using Firefox, set it to the desired download directory and make sure no dialogs pop up and no user interaction is required when downloading files.

对于FirefoxDriver,我们做这个:

For the FirefoxDriver we do this:

File downloadDir = ...;
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.dir", downloadDir.getAbsolutePath());
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "...");
WebDriver driver = new FirefoxDriver(profile);

如何使InternetExplorerDriver达到同样的效果?我找不到InternetExplorerProfile,也没有在DesiredCapabilities中切换。

What to do for InternetExplorerDriver to achieve the same effect? I couldn't find a InternetExplorerProfile nor a switch in DesiredCapabilities.

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("???", "???");
WebDriver driver = new InternetExplorerDriver(capabilities);


推荐答案

Internet Explorer不使用配置文件。这是浏览器本身的限制,而不是IE驱动程序。因此,无法使用Internet Explorer自动将文件下载到指定位置。

Internet Explorer doesn't use profiles. It's a limitation of the browser itself, not the IE driver. As such, there is no way to automatically download files to a specified location with Internet Explorer.

这篇关于如何设置InternetExplorerDriver下载目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 20:50