Is visible
Methods
isVisible
addon/-private/properties/is-visible.js:96-117
Validates if an element or set of elements are visible.
Parameters
- selectorstring CSS selector of the element to check
- optionsObject Additional options- options.scopestring Nests provided scope within parent’s scope
- options.atnumber Reduce the set of matched elements to the one at the specified index
- options.resetScopeboolean Override parent’s scope
- options.multipleboolean Check if all elements matched by selector are visible
- options.testContainerstring Context where to search elements in the DOM
 
- userOptions(optional, default- {})
Examples
// Lorem <span>ipsum</span>
const page = PageObject.create({
  spanIsVisible: PageObject.isVisible('span')
});
assert.ok(page.spanIsVisible);
// <span>ipsum</span>
// <span style="display:none">dolor</span>
const page = PageObject.create({
  spansAreVisible: PageObject.isVisible('span', { multiple: true })
});
// not all spans are visible
assert.notOk(page.spansAreVisible);
// <span>ipsum</span>
// <span>dolor</span>
const page = PageObject.create({
  spansAreVisible: PageObject.isVisible('span', { multiple: true })
});
// all spans are visible
assert.ok(page.spansAreVisible);
// Lorem <strong>ipsum</strong>
const page = PageObject.create({
  spanIsVisible: PageObject.isVisible('span')
});
// returns false when element doesn't exist in DOM
assert.notOk(page.spanIsVisible);
// <div>
//   <span style="display:none">lorem</span>
// </div>
// <div class="scope">
//   <span>ipsum</span>
// </div>
const page = PageObject.create({
  spanIsVisible: PageObject.isVisible('span', { scope: '.scope' })
});
assert.ok(page.spanIsVisible);
// <div>
//   <span style="display:none">lorem</span>
// </div>
// <div class="scope">
//   <span>ipsum</span>
// </div>
const page = PageObject.create({
  scope: '.scope',
  spanIsVisible: PageObject.isVisible('span')
});
assert.ok(page.spanIsVisible);
Returns Descriptor