malloc
malloc

Reputation: 21

Python: Selenium Webdriver Wait EC

I am trying to get data only after the page has been completely loaded; as in after the favicon turns from waiting to site's own icon. The source from where I am trying to get data from gives me 3 tables, these tables have same html so the same xpaths, i tried using:

WebDriverWait(driver,timeout).until(EC.presence_of_element_located((By.CLASS_NAME, "someclass_name")))

But this condition passes as soon as either table is loaded and so my script declares the other two arrays for those tables to be 'None'. Also i tried using 'EC.staleness_of' which didnt work as it passes as soon the another page is loaded i.e; as soon as the page is refreshed. I want a way by which the condition passes only after everything is loaded, not that a particular element is located. Thanks!

Upvotes: 0

Views: 807

Answers (1)

Andersson
Andersson

Reputation: 52685

You can try below code to wait until all 3 tables appears in DOM

WebDriverWait(driver,timeout).until(lambda: len(driver.find_elements_by_class_name("someclass_name")) == 3)

Upvotes: 1

Related Questions