schickling / chromeless

🖥 Chrome automation made simple. Runs locally or headless on AWS Lambda.
https://chromeless.netlify.com
MIT License
13.25k stars 575 forks source link

.visible API #33

Open joelgriffith opened 7 years ago

joelgriffith commented 7 years ago

Ensures that's elements are visible (which is a hard thing to implement in a .evaluate as there's a whole host of things that can make something invisible).

schickling commented 7 years ago

This could be an interesting addition to the API. Would be great to brainstorm on the conditions that make an element invisible, so we have a good foundation for the implementation.

justincy commented 7 years ago

Here's how Selenium/WebDriver defines it:

Determines whether an element is what a user would call "shown". This means that the element is shown in the viewport of the browser, and only has height and width greater than 0px, and that its visibility is not "hidden" and its display property is not "none". Options and Optgroup elements are treated as special cases: they are considered shown iff they have a enclosing select element that is shown.

Elements in Shadow DOMs with younger shadow roots are not visible, and elements distributed into shadow DOMs check the visibility of the ancestors in the Composed DOM, rather than their ancestors in the logical DOM.

Sources:

L0wry commented 7 years ago

@adieuadieu really keen to see this implemented. Lots of user cases where you want to assert or interrogate an element that is in view.

Anything else that you can think of other than what @justincy has provided to help out??

robertpallas commented 7 years ago

I do not think it is important for the element to be in viewport.

Copying Horseman .visible() approach would be enough for me.