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
1 Answer 1
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'))
Explore related questions
See similar questions with these tags.