Nimrod_G
Nimrod_G

Reputation: 941

Selenium - don't wait until all elements are presented

Selenium by default is waiting for all elements to be loaded. Is there any way for waiting for a specific element and then to proceed on? On my test, selenium is waiting with the wait() function for a page to be loaded. sometimes, some images couldn't be loaded from a remote server, while all others element on the page loaded successfully. How can I ask Selenium to ignore waiting all elements except a specific one?

Upvotes: 3

Views: 751

Answers (1)

Avishay
Avishay

Reputation: 335

Selenium works on a copy of the page's source so it try to wait until the DOM represents what will be the page's full source. For this to work correctly selenium is bases on the document.readyState:

  • uninitialized, loading, loaded (waiting)
  • interactive, complete (working).

this behavior is mandatory for work, otherwise the next scenarios might occur and break tests:

  1. Ajax requests that do not return.
  2. Accessing unready elements might cause stale element exceptions.

Upvotes: 1

Related Questions