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

Method withAttrEndsWith

lib/locator.js:362–365  ·  view source on GitHub ↗

* Adds condition: attribute value ends with text * (analog of XPATH: [ends-with(@attr,'endValue')] or CSS [attr$='endValue'] * Example: I.click(locate('a').withAttrEndsWith('href', '.com'))); * Works with any attribute: class, href etc. * @param {string} attrName * @param {string} end

(attrName, endsWith)

Source from the content-addressed store, hash-verified

360 * @returns {Locator}
361 */
362 withAttrEndsWith(attrName, endsWith) {
363 const xpath = sprintf('%s[%s]', this.toXPath(), `substring(@${attrName}, string-length(@${attrName}) - string-length("${endsWith}") + 1) = "${endsWith}"`)
364 return new Locator({ xpath })
365 }
366
367 /**
368 * Adds condition: attribute value contains text

Callers 1

locator_test.jsFile · 0.80

Calls 1

toXPathMethod · 0.95

Tested by

no test coverage detected