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

Method describe

lib/element/WebElement.js:530–547  ·  view source on GitHub ↗

* Plain-object snapshot of the element — text, simplified HTML, visibility, * enabled state, and a curated set of attributes. Each underlying call is * isolated so a single failure (e.g. detached element) doesn't poison the * rest. Suitable for JSON.stringify, log output, MCP tool responses

({ maxHtmlLength = 300, attrs = ['id', 'class', 'name', 'role', 'type', 'href', 'value', 'aria-label', 'placeholder', 'data-testid'] } = {})

Source from the content-addressed store, hash-verified

528 * @returns {Promise<{text?: string, html?: string, visible?: boolean, enabled?: boolean, attrs?: object}>}
529 */
530 async describe({ maxHtmlLength = 300, attrs = ['id', 'class', 'name', 'role', 'type', 'href', 'value', 'aria-label', 'placeholder', 'data-testid'] } = {}) {
531 const out = {}
532 await Promise.all([
533 this.toSimplifiedHTML(maxHtmlLength).then(v => { if (v) out.html = v }, () => {}),
534 this.getText().then(v => { const t = v?.trim(); if (t) out.text = t }, () => {}),
535 this.isVisible().then(v => { out.visible = v }, () => {}),
536 this.isEnabled().then(v => { out.enabled = v }, () => {}),
537 ])
538 const collected = {}
539 await Promise.all(attrs.map(async name => {
540 try {
541 const v = await this.getAttribute(name)
542 if (v != null && v !== '') collected[name] = v
543 } catch {}
544 }))
545 if (Object.keys(collected).length) out.attrs = collected
546 return out
547 }
548
549 // Make accidental JSON.stringify (e.g. returning a WebElement from MCP run_code)
550 // produce a usable hint instead of `{}` — the underlying handle isn't

Callers 1

formatReturnValueFunction · 0.80

Calls 5

toSimplifiedHTMLMethod · 0.95
getTextMethod · 0.95
isVisibleMethod · 0.95
isEnabledMethod · 0.95
getAttributeMethod · 0.95

Tested by

no test coverage detected