如何使用IE更改默认下载目录(Internet Explorer 11)

在这篇文章中,我看到了为Chrome和Firefox设置下载目录的解决方案如何在使用chrome driver / firefox驱动程序时更改Webdriver中的文件下载位置

这些对我来说是完美的(接受的答案),但是我无法找到有关使用Internet Explorer 11执行此操作的任何信息。有谁知道我在哪里可以找到这些信息?

根据Jim Evans的回答 ,他非常关注Internet Explorer的WebDriver,这是不可能的:

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

也:

据我所知,Microsoft Edge和Internet Explorer在使用“配置文件”方面没有区别。 该配置文件仍与Windows中的登录用户帐户绑定。

因此,从某种意义上说,目录已经指定。 关键是你不能通过WebDriver覆盖它。

通过驱动程序无法实现,但您可以使用此注册表项定义位置:

HKCU\Software\Microsoft\Internet Explorer\Main\Default Download Directory 

我正在通过更改REGEDIT来更改默认目录。

 String path = "\"C:\\Test\""; String cmd1 = "REG ADD \"HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\Main\" /F /V \"Default Download Directory\" /T REG_SZ /D "+ path; try { Runtime.getRuntime().exec(cmd1); } catch (Exception e) { System.out.println("Coulnd't change the registry for default directory for IE"); }