Working with cookies

Cookies overview

Cookies are a type of message given to a web browser by a web server. They aim to identify users and potentially prepare customized web pages to prevent the user from having to re-enter information.

Why are they useful?

Cookies essentially customize your web experience! For example, if you visit an online shop for the first time, the site's server sends a file to your computer and automatically installs this file on your machine. As a result, you'll be recognized as a returning visitor the next time you visit the website, and you won't have to re-enter your information.

How many kinds of cookies are there?

There are three main types of cookies: session, permanent, and third-party cookies.

  • Session cookies are primarily used by online shops, and expire when the browser is closed.
  • Permanent cookies are the kind that remain in operation even after closing the browser. They remember your anonymous user ID or login credentials so you can be easily identified and/or authenticated every time you visit a site.
  • There are also third-party cookies, which are installed by external parties that collect certain user information on demographics and behavior.

You can use the mabl Trainer to set cookies and make assertions against cookies and cookie attributes.

How to set a cookie

  1. Click on the plus icon at the bottom of the mabl Trainer window to add a step.
  2. Click on the Cookies step.
  3. Select the Set cookie option.
596596
  1. Fill out the name and value.
  2. Click OK to save the cookie.
596596

Verifying cookies with assertions

If you want create an assertion for a cookie, you can take the following steps:

  1. Click on the check mark icon at the bottom of the mabl Trainer window to create a new assertion.
  2. Select Cookie to assert against a cookie.
  3. Select a cookie from the drop-down menu to view its attributes. The Trainer will automatically populate this drop-down with a list of all cookies that are associated with the current page.
596596

Selecting a cookie

  1. Click OK.
  2. Configure the assertion type, property, and value to compare against. Additional options include disable case sensitivity and continue on failure.
688688

Configuring the cookie assertion

  1. Click OK. You'll now see a step in your test containing the cookie assertion.

Did this page help you?