简体   繁体   中英

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

尝试这个:

driver.find_element_by_tag_name('small').text

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM