Why is the execution time for present? twice as long as visible? in ruby/watir? -
after reading several web pages including testing justin ko says
- exists? – returns whether element exists.
- present? – returns true if element exists , visible on page
- visible? – if parent element isn’t visible cannot write element. reliable way determine iterate dom element tree checking every element make sure it’s visible.
from that
- i predict exists? fastest, because checks see if element exists.
- that present? 2nd fastest checks existence , visibility.
- that visible? slowest because (as read it) has iterate dom element tree.
simply checking 1 element sounds constant-time while iteration sounds linear-time.
i happened running time tests , thought interesting time above methods well. 1 of predictions wrong.
exists? fastest; coming in faster visible? however, present? twice slow visible?
i tried calling methods in different order , enclosing them in 1.upto(10) loop average out times. same results.
something happening here don't understand , i'd understand. know why present? takes twice long visible? or @ least have hypothesis?
it makes sense present? slowest because checks existence and visibility.
def present? exists? && visible? end it make sense take long exists? , visible? combined.
Comments
Post a Comment