MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / exists

Method exists

lib/element/WebElement.js:177–195  ·  view source on GitHub ↗

* Check if element exists in DOM * @returns {Promise } True if element exists

()

Source from the content-addressed store, hash-verified

175 * @returns {Promise<boolean>} True if element exists
176 */
177 async exists() {
178 try {
179 switch (this.helperType) {
180 case 'playwright':
181 // For Playwright, if we have the element, it exists
182 return await this.element.evaluate(el => !!el)
183 case 'webdriver':
184 // For WebDriver, if we have the element, it exists
185 return true
186 case 'puppeteer':
187 // For Puppeteer, if we have the element, it exists
188 return await this.element.evaluate(el => !!el)
189 default:
190 throw new Error(`Unsupported helper type: ${this.helperType}`)
191 }
192 } catch (e) {
193 return false
194 }
195 }
196
197 /**
198 * Get bounding box of the element

Callers 2

WebElement_test.jsFile · 0.80
els_test.jsFile · 0.80

Calls 1

evaluateMethod · 0.80

Tested by

no test coverage detected