Answer the question
In order to leave comments, you need to log in
How to extract desired rows in Python Selenium?
I am using Selenium to parse test responses, all responses are wrapped in a div text /div tag.
Using just find_elements_by_tag_name is not an option, it will display, consider, the entire page.
How to extract the desired lines with content:
div (1. b) / div - etc etc?
Answer the question
In order to leave comments, you need to log in
Use find_element_by_xpath
Then select the reference element, if needed, and extract the desired rows from it
table = driver.find_element_by_xpath('//div[@class="table"]')
rows = table.find_elements_by_xpath('//div')
for row in rows:
print(row.text())
rows = driver.find_element_by_xpath('//div[@class="table"]//div')
for row in rows:
print(row.text())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question