Home > Enterprise >  Selenium can't find locate download link element by ID in Python
Selenium can't find locate download link element by ID in Python

Time:05-29

I'm trying to get Selenium to automate uploading and downloading files from https://8mb.video/ I can upload the file just fine, but after it processes on the site Selenium can't locate the element for the download link even though the ID given matches the ID in the html. Here's my code:

driver = webdriver.Edge()

driver.get('https://8mb.video/')

driver.maximize_window()

driver.get("https://8mb.video/")
s = driver.find_element(By.XPATH, "//input[@type='file']")
s.send_keys("C:\\Users\\ijwto\\Desktop\\VUT\\bladee.mp4")

s = driver.find_element(By.ID, "rockandroll")
s.click()

try:
    element = WebDriverWait(driver, 30).until(
        EC.presence_of_element_located((By.ID, "dllink"))
    )
finally:
    print("nope")

I've also tried using element_to_be_clickable which didn't work, and checked for iframes in the HTML and didn't find any.

Any help would be greatly appreciated.

CodePudding user response:

In order to download the file need to click on the element in the try block

Also if the intention of printing Nope in the finally block is to indicate if the element was not found then it can be added under except instead of finally

Note:- The wait time for WebDriverWait may increase in case the video you are trying to upload is large and the site requires more time to process it

Your solution would like

driver = webdriver.Edge()
driver.get('https://8mb.video/')
driver.maximize_window()
driver.get("https://8mb.video/")
s = driver.find_element(By.XPATH, "//input[@type='file']")
s.send_keys("C:\\Users\\ijwto\\Desktop\\VUT\\bladee.mp4")
s = driver.find_element(By.ID, "rockandroll")
s.click()
try:
    element = WebDriverWait(driver, 30).until(
    EC.presence_of_element_located((By.ID, "dllink"))
    )
    element.click()
except:
  print("Nope")
  • Related