You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Appends Playwright's locator.visible() (1.63+) to locators, so actions
match only visible elements. Resolved per step: stepOpts({ visibleLocator })
overrides the helper config, following exact/strictMode/elementIndex.
seeElementInDOM, dontSeeElementInDOM and seeNumberOfElements opt out by
setting the step option, since they assert DOM presence regardless of
visibility.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D6RydiYkagn6C8Pts2Leou
Copy file name to clipboardExpand all lines: docs/helpers/Playwright.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,8 +78,9 @@ Type: [object][6]
78
78
*`ignoreHTTPSErrors`**[boolean][27]?** Allows access to untrustworthy pages, e.g. to a page with an expired certificate. Default value is `false`
79
79
*`bypassCSP`**[boolean][27]?** bypass Content Security Policy or CSP
80
80
*`highlightElement`**[boolean][27]?** highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
81
+
*`visibleLocator`**[boolean][27]?** append [`visible()`][49] to locators, so only visible elements are matched. Requires Playwright 1.63 or newer. Switch it off for a single step with `stepOpts({ visibleLocator: false })`. Not applied to `dragAndDrop`, which passes selectors to Playwright directly, nor to `seeElementInDOM`, `dontSeeElementInDOM` and `seeNumberOfElements`, which check the DOM regardless of visibility. When enabled, a locator matching only hidden elements fails as "element not found" instead of timing out on actionability, `strict` mode ignores hidden duplicates, and elements hidden by CSS (like a custom checkbox built on a visually hidden `input`) are no longer found.
81
82
*`recordHar`**[object][6]?** record HAR and will be saved to `output/har`. See more of [HAR options][3].
82
-
*`testIdAttribute`**[string][9]?** locate elements based on the testIdAttribute. See more of [locate by test id][49].
83
+
*`testIdAttribute`**[string][9]?** locate elements based on the testIdAttribute. See more of [locate by test id][50].
83
84
*`storageState`**([string][9] | [object][6])?** Playwright storage state (path to JSON file or object)
84
85
passed directly to `browser.newContext`.
85
86
If a Scenario is declared with a `cookies` option (e.g. `Scenario('name', { cookies: [...] }, fn)`),
* @prop {boolean} [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
105
+
* @prop {boolean} [visibleLocator=false] - append [`visible()`](https://playwright.dev/docs/api/class-locator#locator-visible) to locators, so only visible elements are matched. Requires Playwright 1.63 or newer. Switch it off for a single step with `stepOpts({ visibleLocator: false })`. Not applied to `dragAndDrop`, which passes selectors to Playwright directly, nor to `seeElementInDOM`, `dontSeeElementInDOM` and `seeNumberOfElements`, which check the DOM regardless of visibility. When enabled, a locator matching only hidden elements fails as "element not found" instead of timing out on actionability, `strict` mode ignores hidden duplicates, and elements hidden by CSS (like a custom checkbox built on a visually hidden `input`) are no longer found.
105
106
* @prop {object} [recordHar] - record HAR and will be saved to `output/har`. See more of [HAR options](https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har).
106
107
* @prop {string} [testIdAttribute=data-testid] - locate elements based on the testIdAttribute. See more of [locate by test id](https://playwright.dev/docs/locators#locate-by-test-id).
107
108
* @prop {string|object} [storageState] - Playwright storage state (path to JSON file or object)
@@ -399,6 +400,7 @@ class Playwright extends Helper {
399
400
storageState: undefined,
400
401
onResponse: null,
401
402
strict: false,
403
+
visibleLocator: false,
402
404
}
403
405
404
406
process.env.testIdAttribute='data-testid'
@@ -2009,6 +2011,7 @@ class Playwright extends Helper {
2009
2011
* {{> seeElementInDOM }}
2010
2012
*/
2011
2013
asyncseeElementInDOM(locator){
2014
+
disableVisibleLocatorForStep()
2012
2015
constels=awaitthis._locate(locator)
2013
2016
try{
2014
2017
returnempty('elements on page').negate(els.filter(v=>v).fill('ELEMENT'))
@@ -2021,6 +2024,7 @@ class Playwright extends Helper {
2021
2024
* {{> dontSeeElementInDOM }}
2022
2025
*/
2023
2026
asyncdontSeeElementInDOM(locator){
2027
+
disableVisibleLocatorForStep()
2024
2028
constels=awaitthis._locate(locator)
2025
2029
try{
2026
2030
returnempty('elements on a page').assert(els.filter(v=>v).fill('ELEMENT'))
@@ -2398,15 +2402,15 @@ class Playwright extends Helper {
0 commit comments