How to handle "Open this file" in Selenium with webbrowser Edge?

Viewed 441

I have to open an Excel file from SharePoint and refresh it. I can sign in without a problem but I can't handle the "Open this file" prompt from Edge. It's not possible to inspect the prompt that I can locate it. Any ideas?

driver = webdriver.Edge(EdgeChromiumDriverManager().install()) 
driver.get("https://xxx.xlsx")
driver.maximize_window()
driver.find_element(By.XPATH, '//*[@id="i0116"]').send_keys("xxx@xxx.com")
driver.find_element(By.XPATH, '//*[@id="idSIButton9"]').click()
time.sleep(2)

element = driver.find_element_by_link_text("Open")
action = ActionChains(driver)
action.click(on_element = element)
action.perform() 

I tried as well EdgeOptions but I couldn't find the right element.

options = EdgeOptions()
options.use_chromium = True
options.add_experimental_option("prefs", {
  "download.prompt_for_download": False,
  "download.directory_upgrade": True,
  "safebrowsing.enabled": True
})
driver = Edge(options = options)

enter image description here

0 Answers
Related