In our company we are using Selenium for web-automation on Windows. Win runs with signed-in user and locked screen. Recently company changed security for not starting downloading automatically. I need to click with Python on Save As button (while Windows is locked => pyautogui is not a option). What about pywinauto or other lib? thx
CodePudding user response:
If you can still use Selenium, try this out:
NOTE - Tested using Windows 11, Edge 97, Python 3.9, and Selenium 4.1
import os
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.service import Service
# 'executable_path' is deprecated. Use 'service'
driver = webdriver.Edge(
service=Service("C:\\Users\\kabarto\\Documents\\webdrivers\\msedgedriver.exe"))
driver.get("https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/")
# Find the link and use .click to save to Downloads
driver.find_element(
By.XPATH,
"//a[@href=\"https://msedgedriver.azureedge.net/97.0.1072.62/edgedriver_win64.zip\"]"
).click()
# Close browser when download is complete
while not os.path.exists("C:\\Users\\kabarto\\Downloads\\edgedriver_win64.zip"):
time.sleep(1)
driver.quit()
You can also get a list of all the links, and then go through them to find the one you want:
links = driver.find_elements(By.TAG_NAME, "a")
for l in links:
if "win64" in l.get_attribute("href"):
print(l.get_attribute("href"))
CodePudding user response:
I figured it out (work around):
- Before downloading, to open a new tab with Edge Downloads
- To launch downloading (getting pop-up)
- To active tab with Downloads and with Selenium click on particular option (Cancel Save Save As ....)

