Update cookie validation regex in Get Cookies test#1973
Merged
emanlove merged 1 commit intorobotframework:masterfrom Apr 8, 2026
Merged
Update cookie validation regex in Get Cookies test#1973emanlove merged 1 commit intorobotframework:masterfrom
emanlove merged 1 commit intorobotframework:masterfrom
Conversation
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.
There was a problem hiding this comment.
Pull request overview
This PR fixes a flaky acceptance test around Get Cookies by tightening the cookie-string validation so it no longer passes on partial/substring matches caused by incorrectly anchored alternation.
Changes:
- Adds explicit assertions that all three expected cookies are present in the returned cookie string.
- Replaces the prior alternation-based regex with a fully anchored regex that matches exactly three
name=valuecookie pairs (in any order) separated by;.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.