1

Let's say I'm selecting with the selector:

//img[@data-blabla]

And I want to wait for 10 elements to be loaded, not just one.

How would this be modified? I'm making a guess with the index [9]

WebDriverWait(browser, 5).until(EC.presence_of_element_located((By.XPATH, '//img[@data-blabla][9]')))
DebanjanB
  • 118,661
  • 30
  • 168
  • 217
User
  • 20,562
  • 35
  • 99
  • 185

1 Answers1

-1

To wait for 10 elements to load you can use the lambda function and you can use either of the following Locator Strategies:

  • Using >:

    myLength = 9
    WebDriverWait(browser, 20).until(lambda browser: len(browser.find_elements_by_xpath("//img[@data-blabla]")) > int(myLength))
    
  • Using ==:

    myLength = 10
    WebDriverWait(browser, 20).until(lambda browser: len(browser.find_elements_by_xpath("//img[@data-blabla]")) == int(myLength))
    
DebanjanB
  • 118,661
  • 30
  • 168
  • 217