-1

The value of page_length is 100

page_length = driver.find_elements(By.CSS_SELECTOR, "section.PaginationRow-module__container___LxZJN span.PaginationRow-module__lastPage___k9Pq7")
page_len_x = page_length.get_attribute('value')
print(str(page_len_x))

This is my error message :

page_len_x = page_length.get_attribute('value')
AttributeError: 'list' object has no attribute 'get_attribute'

The tag I'm trying to fetch is :

Output

AnxiousDino
  • 187
  • 15

1 Answers1

1

To print the text 100 you need to induce WebDriverWait for the visibility_of_element_located() and you can use either of the following locator strategies:

  • Using CSS_SELECTOR:

    print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "span[class^='PaginationRow-module__lastPage']"))).text)
    
  • Using XPATH:

    print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//span[starts-with(@class, 'PaginationRow-module__lastPage')]"))).text)
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352