@@ -1095,29 +1095,29 @@ describe('Playwright', function () {
10951095 I . see ( 'Information' )
10961096 } )
10971097 } )
1098-
10991098 describe ( '#clearCookie' , ( ) => {
11001099 it ( 'should clear all cookies' , async ( ) => {
1101- I . amOnPage ( '/' )
1102- I . setCookie ( { name : 'test' , value : 'test' } )
1100+ await I . amOnPage ( '/' )
1101+
1102+ await I . setCookie ( { name : 'test' , value : 'test' , url : siteUrl } )
11031103 const cookiesBeforeClearing = await I . grabCookie ( )
1104- assert . equal ( cookiesBeforeClearing . length , 1 )
1105- I . clearCookie ( )
1104+ assert . isAtLeast ( cookiesBeforeClearing . length , 1 )
1105+ await I . clearCookie ( )
11061106 const cookiesAfterClearing = await I . grabCookie ( )
11071107 assert . equal ( cookiesAfterClearing . length , 0 )
11081108 } )
11091109
11101110 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 : 'test2' , value : 'test2' } )
1111+ await I . amOnPage ( '/' )
1112+ await I . setCookie ( { name : 'test1' , value : 'test1' , url : siteUrl } )
1113+ await I . setCookie ( { name : 'test2' , value : 'test2' , url : siteUrl } )
1114+
1115+ const cookiesBeforeRemovingSpecificCookie = await I . grabCookie ( )
1116+ // info: we use "atLeast" instead of "isEqual" here because other random cookies might be set by the page to test.
1117+ assert . isAtLeast ( cookiesBeforeRemovingSpecificCookie . length , 2 )
1118+ await I . clearCookie ( 'test1' )
1119+ const cookiesAfterRemovingSpecificCookie = await I . grabCookie ( )
1120+ assert . equal ( cookiesAfterRemovingSpecificCookie . length , cookiesBeforeRemovingSpecificCookie . length - 1 )
11211121 } )
11221122 } )
11231123} )
0 commit comments