Skip to content

Commit feff894

Browse files
author
Norbert Graf
committed
feature: clear individual cookie by name with Playwright (available since Playwright 1.43)
1 parent c6cbd34 commit feff894

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/helper/Playwright_test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,30 @@ describe('Playwright', function () {
10951095
I.see('Information')
10961096
})
10971097
})
1098+
1099+
describe('#clearCookie', () => {
1100+
it('should clear all cookies', async () => {
1101+
I.amOnPage('/')
1102+
I.setCookie({ name: 'test', value: 'test' })
1103+
const cookiesBeforeClearing = await I.grabCookie()
1104+
assert.equal(cookiesBeforeClearing.length, 1)
1105+
I.clearCookie()
1106+
const cookiesAfterClearing = await I.grabCookie()
1107+
assert.equal(cookiesAfterClearing.length, 0)
1108+
})
1109+
1110+
it('should clear individual cookie by name', async () => {
1111+
I.amOnPage('/')
1112+
I.setCookie({ name: 'test1', value: 'test1' })
1113+
I.setCookie({ name: 'test2', value: 'test2' })
1114+
1115+
const cookiesBeforeClearing = await I.grabCookie()
1116+
assert.equal(cookiesBeforeClearing.length, 2)
1117+
I.clearCookie('test1')
1118+
const cookiesAfterClearing = await I.grabCookie()
1119+
assert.equal(cookiesAfterClearing.length, 1)
1120+
assert.equal(cookiesAfterClearing, { name: 'test1', value: 'test1' })
1121+
})
10981122
})
10991123

11001124
let remoteBrowser

0 commit comments

Comments
 (0)