splinter icon indicating copy to clipboard operation
splinter copied to clipboard

is_element_not_present_by_* are slow

Open kedder opened this issue 12 years ago • 4 comments

is_element_not_present_by_* set of functions are waiting for timeout regardless whether element is present or not. There is a waiting loop in BaseWebDriver.is_element_not_present() that is waiting for negative condition and later in BaseWebDriver.find_by() down in traceback that is waiting for positive condition.

This creates hudnreds of requests to webdriver during wait for condition that is actually satisfied immediately.

kedder avatar Feb 03 '14 11:02 kedder

We can improve it addind a sleep inside the is_element_not_present loop: https://github.com/cobrateam/splinter/blob/master/splinter/driver/webdriver/init.py#L85

andrewsmedina avatar Feb 03 '14 13:02 andrewsmedina

Hm, can you elaborate? That loop in is_element_not_present() actually executes only once if element is not on the page (that is asserted in test). All the waiting takes place in a loop in find_by() (https://github.com/cobrateam/splinter/blob/master/splinter/driver/webdriver/init.py#L196), that waits until the element will appear (and that is not expected).

How would sleep in is_element_not_present() help here?

kedder avatar Feb 03 '14 13:02 kedder

I am facing this question, too. But i use the function in selenium instead to solve this question, like use the find_element_by_xxx in the try/except. it is really fast.

wurenbuxiao avatar Feb 27 '19 06:02 wurenbuxiao

@andrewsmedina This issue has been fixed in 0.13.0. is_element_not_present and is_element_not_visible return the moment the element is not present/visible, instead of retrying.

javascript-error avatar Jan 06 '20 18:01 javascript-error