Selector.filterVisible Method
Returns visible elements.
Selector().filterVisible() → Selector
Visibility Criteria
TestCafe does not interact with invisible elements.
If the element or one of its parents meets the following criteria, TestCafe considers the element to be invisible.
- The value of the element’s
display
property isnone
- The value of the element’s
visibility
property ishidden
orcollapse
- The element has a
width
orheight
of0
.
Elements that do not meet these criteria may still be invisible to the user. The following factors do not influence the element’s visibility status:
- The element’s
z-index
- The element’s
opacity
- The element’s position on the page
Example
// Selects all visible div elements.
const visibleSelectors = Selector('div').filterVisible();