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 4c7b9c3
Browse filesBrowse the repository at this point in the historyBrowse files
authored
feat(retryFailedStep): wakeOnChange retries as soon as the page changes, across all web helpers (#5799)
* feat(retryFailedStep): wakeOnChange option to retry as soon as the page changes
Recorder retry rules accept an optional async beforeRetry(number). When set,
promise-retry runs with zero timeouts and the rule awaits beforeRetry before
each retry attempt. Rules without it behave as before.
retryFailedStep gets a wakeOnChange option (default false). When enabled, it
waits for _waitForChange(delay) on the first helper that implements it, with
the usual backoff delay as an upper bound, and sleeps otherwise.
Playwright implements _waitForChange with a MutationObserver on the page
document raced against a timer; navigation counts as a change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(retryFailedStep): support wakeOnChange in Puppeteer, WebDriver and CDPBrowser
The in-page MutationObserver script moves to lib/helper/scripts/waitForChange.js
and is shared by Playwright, Puppeteer, WebDriver and CDPBrowser (and their
subclasses). WebDriver runs it with executeAsync; a navigation or stale-context
error counts as a change, other errors (e.g. native Appium context) fall back
to the backoff timer. _waitForChange tests move to the shared webapi spec.
wakeOnChange is documented in docs/retry.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(webapi): skip _waitForChange navigation case on Obscura
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/plugins/retryFailedStep.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,7 @@ Run tests with plugin enabled:
43
43
You can use step names or step prefixes ending with `*`. As such, `wait*` will match all steps starting with `wait`.
44
44
To append your own steps to ignore list - copy and paste a default steps list. Regexp values are accepted as well.
45
45
*`deferToScenarioRetries` - when enabled (default), step retries are automatically disabled if scenario retries are configured to avoid excessive total retries.
46
+
*`wakeOnChange` - when enabled, a failed step is retried as soon as the page changes (DOM mutation or navigation) instead of sleeping through the whole backoff. The backoff delay is still the upper bound. Default is false.
46
47
47
48
#### Example
48
49
@@ -58,6 +59,17 @@ plugins: {
58
59
}
59
60
```
60
61
62
+
Retry as soon as the page changes:
63
+
64
+
```js
65
+
plugins: {
66
+
retryFailedStep: {
67
+
enabled:true,
68
+
wakeOnChange:true,
69
+
}
70
+
}
71
+
```
72
+
61
73
#### Disable Per Test
62
74
63
75
This plugin can be disabled per test. In this case you will need to add `step.retry()` to all flaky steps:
Copy file name to clipboardExpand all lines: docs/retry.md
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,6 +109,21 @@ element not found => 0 + (1s+1s) = 2s
109
109
element found but not interactable => 3×5s + (1s+1s) = 17s
110
110
```
111
111
112
+
### Retry on Page Change
113
+
114
+
With `wakeOnChange`, a failed step is retried as soon as the page changes (a DOM mutation or a navigation) instead of sleeping through the whole gap. The gap above stays the upper bound, so on a page that doesn't change the timing is the same:
115
+
116
+
```js
117
+
plugins: {
118
+
retryFailedStep: {
119
+
enabled:true,
120
+
wakeOnChange:true,
121
+
}
122
+
}
123
+
```
124
+
125
+
A step waiting for content that shows up 400ms later passes on that change instead of on the next scheduled retry. A retry can fire in the middle of a render and fail again, which uses up a retry sooner. The option is disabled by default.
Copy file name to clipboardExpand all lines: lib/plugin/retryFailedStep.js
+23Lines changed: 23 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
importdebugModulefrom'debug'
2
+
importContainerfrom'../container.js'
2
3
importeventfrom'../event.js'
3
4
importrecorderfrom'../recorder.js'
4
5
importstorefrom'../store.js'
@@ -14,6 +15,7 @@ const defaultConfig = {
14
15
randomize: false,
15
16
ignoredSteps: [],
16
17
deferToScenarioRetries: true,
18
+
wakeOnChange: false,
17
19
}
18
20
19
21
constRETRY_PRIORITIES={
@@ -62,6 +64,7 @@ const RETRY_PRIORITIES = {
62
64
* You can use step names or step prefixes ending with `*`. As such, `wait*` will match all steps starting with `wait`.
63
65
* To append your own steps to ignore list - copy and paste a default steps list. Regexp values are accepted as well.
64
66
* * `deferToScenarioRetries` - when enabled (default), step retries are automatically disabled if scenario retries are configured to avoid excessive total retries.
67
+
* * `wakeOnChange` - when enabled, a failed step is retried as soon as the page changes (DOM mutation or navigation) instead of sleeping through the whole backoff. The backoff delay is still the upper bound. Default is false.
65
68
*
66
69
* #### Example
67
70
*
@@ -77,6 +80,17 @@ const RETRY_PRIORITIES = {
77
80
* }
78
81
* ```
79
82
*
83
+
* Retry as soon as the page changes:
84
+
*
85
+
* ```js
86
+
* plugins: {
87
+
* retryFailedStep: {
88
+
* enabled: true,
89
+
* wakeOnChange: true,
90
+
* }
91
+
* }
92
+
* ```
93
+
*
80
94
* #### Disable Per Test
81
95
*
82
96
* This plugin can be disabled per test. In this case you will need to add `step.retry()` to all flaky steps:
@@ -105,6 +119,15 @@ export default function (config) {
it('should resolve after the timeout on an idle page',async()=>{
128
+
awaitI.amOnPage('/')
129
+
conststart=Date.now()
130
+
awaitI._waitForChange(300)
131
+
constelapsed=Date.now()-start
132
+
expect(elapsed).to.be.at.least(290)
133
+
expect(elapsed).to.be.lessThan(1000)
134
+
})
135
+
136
+
it('should resolve on navigation',asyncfunction(){
137
+
if(isHelper('Obscura'))this.skip()// on Obscura a script-triggered navigation neither rejects the pending Runtime.evaluate nor mutates the observed document, so the wait runs to its timeout (verified on CI: 3000ms of 3000ms)
0 commit comments