Skip to content

Commit

Permalink
feat(webdriver): network traffics manipulation (#4166)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent committed Feb 7, 2024
1 parent 57beda3 commit f1acf77
Show file tree
Hide file tree
Showing 13 changed files with 864 additions and 337 deletions.
39 changes: 21 additions & 18 deletions docs/helpers/Playwright.md
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,8 @@ I.dontSeeTraffic({ name: 'Unexpected API Call of "user" endpoint', url: /api.exa
- `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.
- `opts.url` **([string][9] | [RegExp][11])** Expected URL of request in network traffic. Can be a string or a regular expression.

Returns **void** automatically synchronized promise through #recorder

### doubleClick

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

Resets all recorded network requests.

```js
I.flushNetworkTraffics();
```

### flushWebSocketMessages

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

Returns **[Promise][22]<[Array][10]<any>>**
Returns **[Array][10]** recorded network traffics

### grabSource

Expand Down Expand Up @@ -2096,26 +2102,26 @@ Verifies that a certain request is part of network traffic.
I.amOnPage('https://openai.com/blog/chatgpt');
I.startRecordingTraffic();
await I.seeTraffic({
name: 'sentry event',
url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
parameters: {
width: '1919',
height: '1138',
name: 'sentry event',
url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
parameters: {
width: '1919',
height: '1138',
},
});
});
```

```js
// checking the request url contains certain post data
I.amOnPage('https://openai.com/blog/chatgpt');
I.startRecordingTraffic();
await I.seeTraffic({
name: 'event',
url: 'https://cloudflareinsights.com/cdn-cgi/rum',
requestPostData: {
st: 2,
name: 'event',
url: 'https://cloudflareinsights.com/cdn-cgi/rum',
requestPostData: {
st: 2,
},
});
});
```

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

Returns **[Promise][22]<any>**
Returns **void** automatically synchronized promise through #recorder

### selectOption

Expand Down Expand Up @@ -2195,15 +2201,12 @@ I.setPlaywrightRequestHeaders({

### startRecordingTraffic

Starts recording the network traffics.
This also resets recorded network requests.
Resets all recorded network requests.

```js
I.startRecordingTraffic();
I.flushNetworkTraffics();
```

Returns **void**

### startRecordingWebSocketMessages

Starts recording of websocket messages.
Expand Down
Loading

0 comments on commit f1acf77

Please sign in to comment.