Simon GIS
Simon GIS

Reputation: 1055

Selenium how to get text element

How to I select in python selenium this element "51,756 results"?

<h1 id="results-list__title" class="t-white t-16 truncate" title="Worldwide">
            Worldwide</h1>
<small aria-live="polite" class="t-white display-flex t-12 t-black--light t-normal">
              51,756 results

<!---->          </small>

my try:

driver.find_element_by_class_name('t-white display-flex t-12 t-black--light t-normal')
    
driver.find_element_by_xpath('.//h1[contains(@class, "t-white display-flex t-12 t-black--light t-normal")]').text

NoSuchElementException: no such element: Unable to locate element

Upvotes: 0

Views: 47

Answers (1)

Md. Fazlul Hoque
Md. Fazlul Hoque

Reputation: 16189

Try this:

driver.find_element_by_tag_name('small').text

Upvotes: 1

Related Questions