* 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)
| 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 |