Skip to content

Commit f1acf77

Browse files
authored
feat(webdriver): network traffics manipulation (#4166)
1 parent 57beda3 commit f1acf77

13 files changed

+864
-337
lines changed

docs/helpers/Playwright.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,8 @@ I.dontSeeTraffic({ name: 'Unexpected API Call of "user" endpoint', url: /api.exa
805805
- `opts.name` **[string][9]** A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
806806
- `opts.url` **([string][9] | [RegExp][11])** Expected URL of request in network traffic. Can be a string or a regular expression.
807807

808+
Returns **void** automatically synchronized promise through #recorder
809+
808810
### doubleClick
809811

810812
Performs a double-click on an element matched by link|button|label|CSS or XPath.
@@ -921,6 +923,10 @@ Returns **void** automatically synchronized promise through #recorder
921923

922924
Resets all recorded network requests.
923925

926+
```js
927+
I.flushNetworkTraffics();
928+
```
929+
924930
### flushWebSocketMessages
925931

926932
Resets all recorded WS messages.
@@ -1309,7 +1315,7 @@ expect(traffics[0].response.status).to.equal(200);
13091315
expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
13101316
```
13111317

1312-
Returns **[Promise][22]<[Array][10]<any>>**
1318+
Returns **[Array][10]** recorded network traffics
13131319

13141320
### grabSource
13151321

@@ -2096,26 +2102,26 @@ Verifies that a certain request is part of network traffic.
20962102
I.amOnPage('https://openai.com/blog/chatgpt');
20972103
I.startRecordingTraffic();
20982104
await I.seeTraffic({
2099-
name: 'sentry event',
2100-
url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
2101-
parameters: {
2102-
width: '1919',
2103-
height: '1138',
2105+
name: 'sentry event',
2106+
url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
2107+
parameters: {
2108+
width: '1919',
2109+
height: '1138',
21042110
},
2105-
});
2111+
});
21062112
```
21072113

21082114
```js
21092115
// checking the request url contains certain post data
21102116
I.amOnPage('https://openai.com/blog/chatgpt');
21112117
I.startRecordingTraffic();
21122118
await I.seeTraffic({
2113-
name: 'event',
2114-
url: 'https://cloudflareinsights.com/cdn-cgi/rum',
2115-
requestPostData: {
2116-
st: 2,
2119+
name: 'event',
2120+
url: 'https://cloudflareinsights.com/cdn-cgi/rum',
2121+
requestPostData: {
2122+
st: 2,
21172123
},
2118-
});
2124+
});
21192125
```
21202126

21212127
#### Parameters
@@ -2127,7 +2133,7 @@ await I.seeTraffic({
21272133
- `opts.requestPostData` **[Object][6]?** Expected that request contains post data in network traffic
21282134
- `opts.timeout` **[number][20]?** Timeout to wait for request in seconds. Default is 10 seconds.
21292135

2130-
Returns **[Promise][22]<any>**
2136+
Returns **void** automatically synchronized promise through #recorder
21312137

21322138
### selectOption
21332139

@@ -2195,15 +2201,12 @@ I.setPlaywrightRequestHeaders({
21952201

21962202
### startRecordingTraffic
21972203

2198-
Starts recording the network traffics.
2199-
This also resets recorded network requests.
2204+
Resets all recorded network requests.
22002205

22012206
```js
2202-
I.startRecordingTraffic();
2207+
I.flushNetworkTraffics();
22032208
```
22042209

2205-
Returns **void**
2206-
22072210
### startRecordingWebSocketMessages
22082211

22092212
Starts recording of websocket messages.

0 commit comments

Comments
 (0)