Using Selenium Library In Python To Automate File Downloads

After weeks of using Power Automate's low code solution to automating file downloads unsuccessfully, I finally turned to Python and Selenium to get the job done. I Was amazed by how easy this was, the hardest part was configuring the webdrivers (What worked best for me was installing the webdriver_manager library and following their documentation.) I'm looking forward to using this to completely automate my reports at work.

from selenium import webdriver

from selenium.webdriver.common.by import By

from selenium.webdriver.firefox.service import Service as FirefoxService

from webdriver_manager.firefox import GeckoDriverManager

import time

browser = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))



elem = browser.find_element(By.XPATH, '/html/body/div[12]/div/div/main/section/div/div/div/article/div/div[2]/article/ul/li[1]/div/div/h3/a')


print("Application title is ", browser.title)

print("Application URL is ", browser.current_url)