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

Method withAttrContains

lib/locator.js:376–379  ·  view source on GitHub ↗

* Adds condition: attribute value contains text * (analog of XPATH: [contains(@attr,'partOfAttribute')] or CSS [attr*='partOfAttribute'] * Example: I.click(locate('a').withAttrContains('href', 'google'))); * Works with any attribute: class, href etc. * @param {string} attrName * @para

(attrName, partOfAttrValue)

Source from the content-addressed store, hash-verified

374 * @returns {Locator}
375 */
376 withAttrContains(attrName, partOfAttrValue) {
377 const xpath = sprintf('%s[%s]', this.toXPath(), `contains(@${attrName}, "${partOfAttrValue}")`)
378 return new Locator({ xpath })
379 }
380
381 /**
382 * Find an element with all of the provided CSS classes (word-exact match).

Callers

nothing calls this directly

Calls 1

toXPathMethod · 0.95

Tested by

no test coverage detected