theintern / leadfoot

A JavaScript client library that brings cross-platform consistency to the Selenium WebDriver API.
Other
170 stars 24 forks source link

Wait for element not visible #104

Closed jimothyhalpert7 closed 7 years ago

jimothyhalpert7 commented 7 years ago

Hi,

Seems like there's no method like this. How would one achieve this? We've tried to do pollUntil and check for the visibility property, but we're a bit confused on how to continue once the element was hidden.

jason0x43 commented 7 years ago

We'd like to keep this issue tracker focused on development, so we ask that only bugs and specific feature requests be filed here. For usage questions, StackOverflow is the preferred venue.

That being said...

pollUntil is a reasonable way to achieve this. The pollUntil helper will repeatedly check for a condition. When the condition is met, execution will continue past pollUntil. If the condition isn't met within a certain timeout, the promise chain will be rejected.

The specific condition you'd check for depends on how the element is being hidden. For example, if visibility is being set, you could check the element's visibility style attribute, something like pollUntil('return document.getElementById("myelement").style.visibility === "hidden" ? true : null;', 1000). A key point to keep in mind with pollUntil is that the poller should return null or undefined if the condition is not met, or anything else if it is.