Objective
File download time will pop up a download option box, this frame is not located, some elements are destined not to be able to locate it does not matter, when there is no mouse, we can use the keyboard shortcut keys to complete the operation.
SendKeys Library is a professional handling of keyboard events, so here need to use SendKeys to solve
First, download the scene
1. When you click the Download button, the following page pops up
2. If you want to click "Save File" button, solve the problem idea:
-First press TAB, move cursor focus to save button
-Press the ENTER key again, so that you can save the
Second, the Code implementation
#Coding:utf-8 fromSeleniumImportWebdriverImportSendKeysImportTimedriver=Webdriver. Firefox () Driver.get ("Https://www.autoitscript.com/files/autoit3/autoit-v3-setup.exe") Time.sleep (3)#by default on the Cancel button, first switch to save fileSendkeys.sendkeys ("{TAB}")#Send Tab keyTime.sleep (3)#The first time you enter the Firefox is not effective, so more than once returnSendkeys.sendkeys ("{ENTER}")#Send EnterSendkeys.sendkeys ("{ENTER}")#Send Enter
Selenium+python Automation 79-File Download (SendKeys)