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]')))
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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With