Skip to content

Commit 54ba867

Browse files
authored
Update cookie validation regex in Get Cookies test
Fix flaky Get Cookies test The previous regex used | to handle any cookie ordering, but the ^ and $ anchors were not wrapping both alternatives, leaving each side only partially anchored and allowing substring matches. For example, the first alternative only required the string to start with test=seleniumlibrary; another=value, meaning a third cookie appended at the end would still pass. All 3 cookies were always being returned, but the test was silently passing in the past because the browser was consistently returning cookies in an order that accidentally satisfied the faulty regex. Replaced the regex with a stricter pattern that matches exactly 3 known cookies in any order, with no room for unexpected extras.
1 parent 423ebb8 commit 54ba867

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

atest/acceptance/keywords/cookies.robot

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ Library DateTime
99
*** Test Cases ***
1010
Get Cookies
1111
${cookies}= Get Cookies
12+
Should Contain ${cookies} test=seleniumlibrary
13+
Should Contain ${cookies} another=value
14+
Should Contain ${cookies} far_future=timemachine
1215
Should Match Regexp ${cookies}
13-
... ^(test=seleniumlibrary; another=value)|(another=value; test=seleniumlibrary)$
16+
... ^(?:test=seleniumlibrary|another=value|far_future=timemachine)(?:; (?:test=seleniumlibrary|another=value|far_future=timemachine)){2}$
1417

1518
Get Cookies As Dict
1619
${cookies}= Get Cookies as_dict=True

0 commit comments

Comments
 (0)