Home > Mobile >  Selenium how to get text element
Selenium how to get text element

Time:11-02

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

CodePudding user response:

Try this:

driver.find_element_by_tag_name('small').text
  • Related