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
{{ message }}
Repository navigation
Commit af89cc9
Browse filesBrowse the repository at this point in the historyBrowse files
* feat(playwright): add instantAnimations and blockResources options
instantAnimations sets the CDP Animation playback rate to 1000 on every
page of a context (Chromium only), so clicks on animated elements no
longer wait for the animation to finish. blockResources aborts requests
of the listed resource types (image, media, font, stylesheet) through a
context route.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(playwright): keep resource blocker when stopMockingRoute('**/*') is called
Register the blockResources route with a predicate so unroute by URL
pattern cannot remove it. Regenerate helper docs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(playwright): move blockResources out of this change
blockResources becomes an option for all web helpers in a separate
change. This branch keeps instantAnimations only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: DavertMik <davert@testomat.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/helpers/Playwright.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,6 +79,7 @@ Type: [object][8]
79
79
*`bypassCSP`**[boolean][26]?** bypass Content Security Policy or CSP
80
80
*`highlightElement`**[boolean][26]?** highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
81
81
*`visibleLocator`**[boolean][26]?** 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 steps that must reach hidden elements: `grab*` methods, `scrollTo`, `seeElementInDOM`, `dontSeeElementInDOM` and `seeNumberOfElements`. 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.
82
+
*`instantAnimations`**[boolean][26]?** run CSS transitions, CSS animations and Web Animations 1000 times faster, so a click waits for a moving element for one frame instead of the whole animation. `transitionend` and `animationend` still fire. Chromium only. Timers and JS-driven animations keep their speed. Not applied inside cross-origin iframes that Chromium runs in a separate process.
82
83
*`recordHar`**[object][8]?** record HAR and will be saved to `output/har`. See more of [HAR options][3].
83
84
*`testIdAttribute`**[string][7]?** locate elements based on the testIdAttribute. See more of [locate by test id][50].
84
85
*`storageState`**([string][7] | [object][8])?** Playwright storage state (path to JSON file or object)
To master request intercepting [use `route` object](https://playwright.dev/docs/api/class-route) object passed into mock request handler.
466
466
467
+
## Instant Animations
468
+
469
+
Enable `instantAnimations` to cut the time a test spends waiting for animations:
470
+
471
+
```js
472
+
helpers: {
473
+
Playwright: {
474
+
url:'http://localhost:3000',
475
+
instantAnimations:true,
476
+
},
477
+
}
478
+
```
479
+
480
+
`instantAnimations` runs CSS transitions, CSS animations and Web Animations 1000 times faster on every page and tab. Playwright waits for an element to stop moving before clicking it, so a click on an element inside a 3 second transition takes about 100ms instead of 3 seconds. `transitionend` and `animationend` events still fire.
481
+
482
+
* Chromium only. Firefox and WebKit ignore the option.
483
+
* `setTimeout`, `setInterval` and JavaScript-driven animations (like jQuery `animate`) keep their speed.
484
+
* Not applied inside cross-origin iframes that Chromium runs in a separate process (site isolation).
485
+
467
486
## Video <Badge text="Since 3.1" type="warning"/>
468
487
469
488
Playwright may record videos for failed tests. This can be enabled in a config with `video:true` option:
* @prop {boolean} [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
109
109
* @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 steps that must reach hidden elements: `grab*` methods, `scrollTo`, `seeElementInDOM`, `dontSeeElementInDOM` and `seeNumberOfElements`. 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.
110
+
* @prop {boolean} [instantAnimations=false] - run CSS transitions, CSS animations and Web Animations 1000 times faster, so a click waits for a moving element for one frame instead of the whole animation. `transitionend` and `animationend` still fire. Chromium only. Timers and JS-driven animations keep their speed. Not applied inside cross-origin iframes that Chromium runs in a separate process.
110
111
* @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).
111
112
* @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).
112
113
* @prop {string|object} [storageState] - Playwright storage state (path to JSON file or object)
@@ -419,6 +420,7 @@ class Playwright extends Helper {
419
420
onResponse: null,
420
421
strict: false,
421
422
visibleLocator: false,
423
+
instantAnimations: false,
422
424
}
423
425
424
426
process.env.testIdAttribute='data-testid'
@@ -681,6 +683,7 @@ class Playwright extends Helper {
681
683
throwerr
682
684
}
683
685
}
686
+
awaitthis._setupContext(this.browserContext)
684
687
}
685
688
}
686
689
@@ -695,6 +698,7 @@ class Playwright extends Helper {
0 commit comments