Passer au contenu principal

isExisting

Returns true if element exists in the DOM.

information

As opposed to other element commands WebdriverIO will not wait for the element to exist to execute this command.

Usage
$(selector).isExisting()
Examples
index.html
<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>
isExisting.js
it('should detect if elements are existing', async () => {
let elem = await $('#someRandomNonExistingElement')
let isExisting = await elem.isExisting()
console.log(isExisting); // outputs: false

elem = await $('#notDisplayed')
isExisting = await elem.isExisting()
console.log(isExisting); // outputs: true

elem = await $('#notVisible')
isExisting = await elem.isExisting()
console.log(isExisting); // outputs: true

elem = await $('#notInViewport')
isExisting = await elem.isExisting()
console.log(isExisting); // outputs: true

elem = await $('#zeroOpacity')
isExisting = await elem.isExisting()
console.log(isExisting); // outputs: true
});

Welcome! How can I help?

WebdriverIO AI Copilot