Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Cyber Security
  3. Question
Cyber Security

How can I use the find_elements_by_xpath?

Asked by Ankit Yadav Feb 24, 2022 1.1K views 1 answer
Share

About this question

 How should I use driver.find_elements_by_xpath() to get all the data-row elements? 

I do not need the other tr tags. In my current code I just check all the tr tags and then throw out the ones that raise a NoSuchElementException but that gets very slow since my implicit_wait() is set to 15 seconds and the table is about 100 rows long, see below for code snippet.


table_element = t_find_element_by_id(driver, "table_name")
body_element = t_find_element_by_tag_name(table_element, "tbody")
row_elements = t_find_elements_by_tag_name(body_element, "tr")
for item in row_elements:
    column_elements = t_find_elements_by_tag_name(item, "td")
    try:
        a_tag_element = t_find_element_by_tag_name(columns[0], 'a')
    except NoSuchElementException:
        continue

Your answer

1 Answer

More Cyber Security discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Cyber Security Blogs

Guides, tips and career advice on Cyber Security from JanBask experts.