Skip to content

feat(webdriver): network traffics manipulation #4166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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