codeceptjs 4.0.0-rc.16 → 4.0.0-rc.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/locator.js +12 -1
  2. package/package.json +1 -1
package/lib/locator.js CHANGED
@@ -591,13 +591,24 @@ Locator.clickable = {
591
591
  `.//*[@title = ${literal}]`,
592
592
  `.//*[@aria-labelledby = //*[@id][normalize-space(string(.)) = ${literal}]/@id ]`,
593
593
  `.//*[@role='button'][normalize-space(.)=${literal}]`,
594
+ `.//*[@role='tab' or @role='link' or @role='menuitem' or @role='menuitemcheckbox' or @role='menuitemradio' or @role='option' or @role='treeitem'][contains(normalize-space(string(.)), ${literal})]`,
594
595
  ]),
595
596
 
596
597
  /**
597
598
  * @param {string} literal
598
599
  * @returns {string}
599
600
  */
600
- self: literal => `./self::*[contains(normalize-space(string(.)), ${literal}) or contains(normalize-space(@value), ${literal})]`,
601
+ self: literal => {
602
+ // Narrowest-match: prefer the deepest descendant whose string-value contains the literal.
603
+ // Falling back to `self` without the `not(descendant...)` guard would match a container
604
+ // whose concatenated text happens to include the literal (e.g. a <ul role="tablist"> whose
605
+ // tab labels all sit in its string-value) and click the container itself.
606
+ const narrowest = `contains(normalize-space(string(.)), ${literal}) and not(.//*[contains(normalize-space(string(.)), ${literal})])`
607
+ return xpathLocator.combine([
608
+ `.//*[${narrowest}]`,
609
+ `./self::*[${narrowest} or contains(normalize-space(@value), ${literal})]`,
610
+ ])
611
+ },
601
612
  }
602
613
 
603
614
  Locator.field = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "4.0.0-rc.16",
3
+ "version": "4.0.0-rc.17",
4
4
  "type": "module",
5
5
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
6
6
  "keywords": [