使用Python和Selenium在Internet Explorer 11中自动下载文件 [英] Download files automatically in Internet Explorer 11 with Python and Selenium

查看:116
本文介绍了使用Python和Selenium在Internet Explorer 11中自动下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Python和Selenium通过多个Internet Explorer 11窗口同时下载一些Excel文件.当另存为"弹出窗口出现且单击保存按钮的唯一方法是发送键(alt + s)时,问题就会出现.但是要做到这一点,重点必须放在浏览器窗口上,正如我之前所说,我需要同时启动多个IE11窗口并执行相同的操作.

I am trying to download some Excels files throught multiple Internet Explorer 11 windows at the same time by using Python and Selenium. The problem appens when the "Save As" Pop Up appears and the only way to click to save button is send keys (alt + s). But to do that, the focus must be over the browser window, and as I sais before, I need launch mulitples IE11 windows at the same time and doing the same thing.

诸如AutoIt,Robot或仅用于事件发送键之类的工具无效,因为这些工具使用操作系统,我认为必须有诸如javascript或Python之类的解决方案来处理应能正常工作的每个窗口浏览器.

Tools like AutoIt, Robot or just events send keys doesn't be valid because these tools use operating system, I think there must be a solution like javascript, or Python to handle each window browser that should works.

感谢您的帮助,谢谢!

推荐答案

在Java中尝试下载文件.

Tried in Java, file was dowloaded.

driver.findElement(By.xpath("//body")).sendKeys(Keys.chord(Keys.CONTROL, "j"));
Thread.sleep(2000);
Robot rb = new Robot();
rb.keyPress(KeyEvent.VK_ENTER);

说明:

  1. 首先单击按钮/链接以下载文件.将看到此弹出窗口
  2. 点击"Ctrl + j"这将打开查看下载弹出窗口".然后点击Enter,因为焦点将集中在最近的文件上,因此将被下载

这篇关于使用Python和Selenium在Internet Explorer 11中自动下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆