user321627
user321627

Reputation: 2572

How to pull out text within an h3 tag class in selenium using python?

I currently am having difficulty extracting text from the following page:

enter image description here

I have tried browser.find_element_by_class_name("W6bZuc.YMllz").text

and also

browser.find_element_by_tag_name("h3").text

but these all come up empty. Is there a way to get the h3 element consistently using selenium webdriver in python? Thanks.

Upvotes: 0

Views: 880

Answers (2)

frianH
frianH

Reputation: 7563

Try use .get_attribute('innerHTML'):

driver.find_element_by_css_selector('.W6bZuc.YMllz').get_attribute('innerHTML')

Upvotes: 1

supputuri
supputuri

Reputation: 14135

Try getting textContent

browser.find_element_by_class_name("W6bZuc.YMllz").get_attribute("textContent")

Upvotes: 1

Related Questions