0

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!

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

3 Comments

Great! How about a more general case? For example; the page actually returns at most 3 tables, more like if the elements are dynamic what would be the best way?
@Andersson Is lambda supported by Python 3.6.1 on Windows as well? Can you please refer me some documentations on the usage and implementation of lambda? Thanks
@DebanjanB, Yes, anonymous functions are supported by 3.6.1 version. You can get some description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.