Skip to content

Commit 395443e

Browse files
inancgumuska3de
authored andcommitted
Improve addCookies example
Resolves: #1328 (comment)
1 parent 9978dd4 commit 395443e

File tree

1 file changed

+10
-3
lines changed
  • src/data/markdown/docs/02 javascript api/07 k6-experimental/01 browser/02 BrowserContext

1 file changed

+10
-3
lines changed

src/data/markdown/docs/02 javascript api/07 k6-experimental/01 browser/02 BrowserContext/addCookies.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default async function () {
4848
name: 'testcookie',
4949
value: '1',
5050
sameSite: 'Strict',
51-
domain: '127.0.0.1',
51+
domain: 'httpbin.org',
5252
path: '/',
5353
httpOnly: true,
5454
secure: true,
@@ -58,7 +58,7 @@ export default async function () {
5858
name: 'testcookie2',
5959
value: '2',
6060
sameSite: 'Lax',
61-
domain: '127.0.0.1',
61+
domain: 'httpbin.org',
6262
path: '/',
6363
expires: dayAfter,
6464
},
@@ -67,11 +67,18 @@ export default async function () {
6767
name: 'testcookie3',
6868
value: '3',
6969
sameSite: 'Lax',
70-
domain: '127.0.0.1',
70+
domain: 'httpbin.org',
7171
path: '/',
7272
expires: dayBefore
7373
}
7474
]);
75+
76+
const response = await page.goto('https://httpbin.org/cookies', {
77+
waitUntil: 'networkidle',
78+
});
79+
console.log(response.json());
80+
// prints:
81+
// {"cookies":{"testcookie":"1","testcookie2":"2"}}
7582
} finally {
7683
page.close();
7784
}

0 commit comments

Comments
 (0)