0

I have multiple link on webpage with button. I wanted to validate and ensure all link are working. Do not want to download each file and wait till gets finished. After successful download to check file whether its as expected?

Problem : My approach is to extract download link from web element and validate link itself. But failing to extract download link :(

Solutions I have tried :

Tried finding element using different locator strategy: like xpath, class_name, css_selector, id & even combination of two locators adv strategy too

Team, Let me know if you have faced and applied working solution for this issue. Thanks!

System :

Python Selenium Edge browser & Chrome Target : any browser

asked Dec 3, 2022 at 19:06

1 Answer 1

0

Working solution :

  • My targeted web has data-link attribute inside DOM for specific download button/element
  • I have preferred to use find_elements to get list of all available download link and iterated according to requirement
# Waiting for element
WebDriverWait(context.driver, 40, 0.4).until(EC.presence_of_element_located((By.CSS_SELECTOR, 'button:nth-child(2)')))
# Identified element which has download link under attribute "data-link" & iterated to print all available links 
elements = context.driver.find_elements(By.CSS_SELECTOR, 'button:nth-child(2)')
 for element in elements:
 print(" >> Download link is : ", element.get_attribute('data-link'))
answered Dec 3, 2022 at 19:06

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.