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

Method withAttrStartsWith

lib/locator.js:348–351  ·  view source on GitHub ↗

* Adds condition: attribute value starts with text * (analog of XPATH: [starts-with(@attr,'startValue')] or CSS [attr^='startValue'] * Example: I.click(locate('a').withAttrStartsWith('href', 'https://'))); * Works with any attribute: class, href etc. * @param {string} attrName * @para

(attrName, startsWith)

Source from the content-addressed store, hash-verified

346 * @returns {Locator}
347 */
348 withAttrStartsWith(attrName, startsWith) {
349 const xpath = sprintf('%s[%s]', this.toXPath(), `starts-with(@${attrName}, "${startsWith}")`)
350 return new Locator({ xpath })
351 }
352
353 /**
354 * Adds condition: attribute value ends with text

Callers 1

locator_test.jsFile · 0.80

Calls 1

toXPathMethod · 0.95

Tested by

no test coverage detected