View Source Improve this doc

isVisible

Return true if the selected DOM-element found by given selector is visible. Returns an array if multiple DOM-elements are found for the given selector.

Usage

1
browser.isVisible(selector);

Parameters

Param Type Details
selector String DOM-element

Example

index.html
1
2
3
4
<div id="notDisplayed" style="display: none"></div>
<div id="notVisible" style="visibility: hidden"></div>
<div id="notInViewport" style="position:absolute; left: 9999999"></div>
<div id="zeroOpacity" style="opacity: 0"></div>
isVisible.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
it('should detect if an element is visible', function () {
var isVisible = browser.isVisible('#notDisplayed');
console.log(isVisible); // outputs: false

isVisible = browser.isVisible('#notVisible');
console.log(isVisible); // outputs: false

isVisible = browser.isVisible('#notExisting');
console.log(isVisible); // outputs: false

isVisible = browser.isVisible('#notInViewport');
console.log(isVisible); // outputs: true

isVisible = browser.isVisible('#zeroOpacity');
console.log(isVisible); // outputs: true
});

Returns

  • <Boolean/Boolean[]>: true if element(s)* [is|are] visible

Uses