What You'll Learn
How to write cookie assertions in your test cases
Best practices for checking cookie properties
The cookie properties you can assert on
Before You Start
Make sure you have an existing test case ready
How to Add a Cookie Assertion
Open your test case: Navigate to the test case where you want to check cookie behaviour.
Add a new step [Add a reference here]:
Click Add a new step and type the description of the assertion, or
Describe what you want in chat (for example: “Add a step to check the login cookie is present and secure”).
Write your assertion: Write a brief description of the cookie and properties you want to assert on. You can assert on:
The name of the cookie
The value of the cookie
The domain of the cookie
The path of the cookie
Whether the cookie has HTTPOnly and Secure properties
The expiration date of the cookie
How long until it expires?
Once you are done adding all your assertions, you will have a test case similar to this one:
Execute your test case:
You can now execute your test case and let ThunderCode ensure you have the right cookies.
Tips for Writing Effective Cookie Assertions
Focus on what matters: Only check properties that are important for your scenario.
Example: Check that the cookie X has the path / and isn’t expired
Be flexible with dynamic values: It’s okay to give a general description of the value if it changes often.
Example: Check that the auth cookie has the word token in its value
Adjust assertion granularity: You can make assertions as detailed or broad as needed.
For precise checks: "Verify the auth cookie is secure, HTTP-only, and expires in 24 hours"
For general checks: "Ensure there are exactly 4 cookies" or "Verify no cookies are expired"