I want to create a line of code that looks for a specific string of text in all child and sub-child elements of an already defined element. Below is a sample web page code to illustrate (forgive me if the html and css are bad):
<div class="className">
<div>TEXT 01</div>
<div>TEXT 02</div>
<div>
<div>TEXT 03</div>
</div>
<div>
<div></div>
<div>TEXT 04</div>
<div></div>
</div>
</div>
I want Selenium to analyze all text inside of the main div and return that text, including TEXT 01, TEXT 02, TEXT 03, TEXT 04. Here's what I have so far:
parent_element = driver.find_element_by_class_name('className')
test = parent_element.find_element_by_xpath('.//*').text
print(test)
Unfortunately, this is not working to return all of the text. Any ideas? THANKS!