I'm trying to get "Home" text from
<li class="active"><a href="#">Home</a></li>
I tried
element = self.browser.find_element_by_class_name('active')
print element.find_element_by_tag_name('a').text
but it returns empty string. What am I missing here?
Do it using CSS - .find_element_by_css_selector("li.active a")
, or using xpath .find_element_by_xpath("//li[@class='active']/a")
So this is how it would like finally
element = self.browser.find_element_by_css_selector("li.active a")
print element.text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With