Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:MarketSquare Robotframework browser Cookie Keywords

From Leeroopedia
Revision as of 11:29, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/MarketSquare_Robotframework_browser_Cookie_Keywords.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Cookie, BrowserControl
Last Updated 2026-02-12 05:40 GMT

Overview

Provides keywords for managing browser cookies in the current active browser context, including retrieval, creation, deletion, and inspection of individual cookies.

Description

The Cookie class extends LibraryComponent and provides five primary Robot Framework keywords for cookie management. Get Cookies retrieves all cookies from the active browser context, returning them as either a list of Robot Framework dot dictionaries or a semicolon-separated string (controlled by the return_type parameter). Get Cookie retrieves a single cookie by name, raising a ValueError if not found. Add Cookie creates a new cookie with configurable properties including name, value, url, domain, path, expires, httpOnly, secure, and sameSite. The expires parameter supports Robot Framework DateTime formats, epoch timestamps, and Python datetime objects. Delete All Cookies removes all cookies from the active context. An easter egg keyword Eat All Cookies is also provided. Internal helper methods handle cookie formatting between dict, DotDict, and string representations, as well as expiry date parsing logic.

Usage

Use these keywords when you need to manage browser cookies during testing, for example to set authentication cookies, verify cookie values after login, clear cookies between test scenarios, or test cookie-dependent functionality such as session management and user preferences.

Code Reference

Source Location

Signature

class Cookie(LibraryComponent):

    def get_cookies(
        self, return_type: CookieType = CookieType.dictionary
    ) -> list[DotDict] | str:

    def add_cookie(
        self,
        name: str,
        value: str,
        url: str | None = None,
        domain: str | None = None,
        path: str | None = None,
        expires: str | datetime | None = None,
        httpOnly: bool | None = None,
        secure: bool | None = None,
        sameSite: CookieSameSite | None = None,
    ):

    def delete_all_cookies(self):

    def get_cookie(
        self, cookie: str, return_type: CookieType = CookieType.dictionary
    ) -> DotDict | str:

    def eat_all_cookies(self):

Import

from Browser.keywords.cookie import Cookie

I/O Contract

Inputs

Name Type Required Description
return_type CookieType No Type of return value: dictionary (DotDict) or string. Default is dictionary.
name str Yes (for add_cookie) Name of the cookie to add.
value str Yes (for add_cookie) Value to assign to the cookie.
url str or None No URL scope for the cookie. Either url or domain/path pair must be set.
domain str or None No Domain scope for the cookie.
path str or None No Path scope for the cookie.
expires str, datetime, or None No Cookie expiry. Supports Robot Framework DateTime formats, epoch timestamps, or Python datetime objects.
httpOnly bool or None No When true, the cookie is not accessible via JavaScript.
secure bool or None No When true, the cookie is only sent over HTTPS.
sameSite CookieSameSite or None No SameSite attribute for cross-origin request policy.
cookie str Yes (for get_cookie) Name of the specific cookie to retrieve.

Outputs

Name Type Description
cookies list[DotDict] or str List of cookie dot dictionaries or semicolon-separated string of name=value pairs (from get_cookies).
cookie DotDict or str Single cookie as a dot dictionary (with keys: name, value, url, domain, path, expires, httpOnly, secure, sameSite) or as a name=value string (from get_cookie).

Usage Examples

Robot Framework

*** Test Cases ***
Get All Cookies As Dictionary
    ${cookies}=    Get Cookies
    Log    ${cookies}

Get All Cookies As String
    ${cookies}=    Get Cookies    return_type=string
    Should Contain    ${cookies}    session_id=

Add And Verify Cookie
    Add Cookie    foo    bar    http://address.com/path/to/site
    ${cookie}=    Get Cookie    foo
    Should Be Equal    ${cookie.value}    bar

Add Cookie With Expiry
    Add Cookie    foo    bar    http://address.com/path/to/site    expires=2027-09-28 16:21:35

Delete All Cookies
    Delete All Cookies
    ${cookies}=    Get Cookies
    Should Be Empty    ${cookies}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment