TestKase Docs
AutomationTest Frameworks

Robot Framework

Set up Robot Framework for acceptance testing and integrate test results with TestKase.

Overview

Robot Framework is a generic open-source automation framework for acceptance testing and robotic process automation (RPA). It uses a keyword-driven syntax in .robot files, making tests highly readable without requiring programming knowledge. Robot Framework is Python-based and has a rich ecosystem of libraries for web, API, database, and desktop testing.

To integrate Robot Framework results with TestKase, generate JUnit-compatible XML output using the built-in --xunit flag and report with --format junit.

Prerequisites

  • Python 3.8+
  • pip

Installation

Install Robot Framework:

pip install robotframework

For web testing, install one of the browser libraries:

# Selenium-based
pip install robotframework-seleniumlibrary

# Playwright-based (recommended for modern web apps)
pip install robotframework-browser
rfbrowser init

For API testing:

pip install robotframework-requests

Project Setup

Directory Structure

my-project/
  tests/
    login.robot
    dashboard.robot
  resources/
    common.resource
    variables.robot
  results/                 # Generated after running tests
    robot-junit.xml
    output.xml
    log.html
    report.html

Resource File

Create a shared resource file with common variables and keywords (e.g., resources/common.resource):

*** Settings ***
Library    SeleniumLibrary

*** Variables ***
${BASE_URL}     http://localhost:3000
${BROWSER}      headlesschrome

*** Keywords ***
Open Login Page
    Open Browser    ${BASE_URL}/login    ${BROWSER}
    Wait Until Page Contains Element    id:email

Enter Credentials
    [Arguments]    ${email}    ${password}
    Input Text    id:email    ${email}
    Input Text    id:password    ${password}

Click Login Button
    Click Button    id:login-button
    Wait Until Page Does Not Contain Element    id:login-button    timeout=5s

Close Test Browser
    Close All Browsers

Variables File

*** Variables ***
${VALID_EMAIL}       user@example.com
${VALID_PASSWORD}    password123
${INVALID_PASSWORD}  wrong

Writing Tests

Create a test file (e.g., tests/login.robot):

*** Settings ***
Resource    ../resources/common.resource
Variables   ../resources/variables.robot
Suite Setup       Open Login Page
Suite Teardown    Close Test Browser

*** Test Cases ***
[48271] Valid Login Test
    [Documentation]    Verify that a user can log in with valid credentials
    Enter Credentials    ${VALID_EMAIL}    ${VALID_PASSWORD}
    Click Login Button
    Page Should Contain    Dashboard

[48272] Invalid Password Test
    [Documentation]    Verify that an error is shown for invalid password
    Enter Credentials    ${VALID_EMAIL}    ${INVALID_PASSWORD}
    Click Login Button
    Page Should Contain    Invalid credentials

[48273] Empty Email Test
    [Documentation]    Verify that email field is required
    Enter Credentials    ${EMPTY}    ${VALID_PASSWORD}
    Click Login Button
    Page Should Contain    Email is required

Each test case name includes a 5-digit Automation ID in square brackets. The @testkase/reporter CLI extracts these IDs using the regex \[(\d{5})\]. For the example above:

  • 48271 → linked to the "valid login" test case in TestKase
  • 48272 → linked to the "invalid password" test case in TestKase
  • 48273 → linked to the "empty email" test case in TestKase

Generate Automation IDs in TestKase first, then embed them in your test case names. The [XXXXX] pattern can appear anywhere in the test name — the reporter extracts all 5-digit IDs found in brackets.

Running Tests

Run all tests:

robot tests/

Run a specific test file:

robot tests/login.robot

Generating JUnit XML Output

Use the --xunit flag to generate JUnit-compatible XML:

robot --xunit test-results/robot-junit.xml tests/

This generates the JUnit XML alongside the standard Robot Framework output files (output.xml, log.html, report.html).

You can combine with other output options:

robot --xunit test-results/robot-junit.xml --outputdir results tests/

The --xunit flag must be placed before the test path argument. Placing it after will cause Robot Framework to treat it as a test file path.

TestKase Integration

After generating the JUnit XML file, report results to TestKase:

npx @testkase/reporter report \
  --token $TESTKASE_PAT \
  --project-id PRJ-1 \
  --org-id 1173 \
  --cycle-id TCYCLE-5 \
  --format junit \
  --results-file test-results/robot-junit.xml

--cycle-id is optional. If not provided, results are reported to TCYCLE-1 — the master test cycle for the project.

Automation ID Mapping

The reporter extracts 5-digit Automation IDs from Robot Framework test names using the [XXXXX] bracket pattern:

Test PatternTest NameExtracted ID
Test in login.robot[48271] Valid Login Test48271
Test in dashboard.robot[48274] Widget Loads Correctly48274
Nested suite[48275] Token Validation Test48275

The [XXXXX] pattern can appear anywhere in the test case name. The suite hierarchy does not affect the Automation ID — only the 5-digit number inside brackets matters.

Complete Example

1. Test File

*** Settings ***
Library    SeleniumLibrary
Suite Setup       Open Browser    http://localhost:3000/login    headlesschrome
Suite Teardown    Close All Browsers

*** Test Cases ***
[48271] Valid Login Test
    Input Text    id:email    user@example.com
    Input Text    id:password    password123
    Click Button    id:login-button
    Wait Until Page Contains    Dashboard

[48272] Invalid Password Test
    Input Text    id:email    user@example.com
    Input Text    id:password    wrong
    Click Button    id:login-button
    Wait Until Page Contains    Invalid credentials

2. Run Tests and Generate JUnit XML

robot --xunit test-results/robot-junit.xml tests/

3. Report Results to TestKase

npx @testkase/reporter report \
  --token $TESTKASE_PAT \
  --project-id PRJ-1 \
  --org-id 1173 \
  --cycle-id TCYCLE-5 \
  --format junit \
  --results-file test-results/robot-junit.xml

Troubleshooting

xunit file not generated

Ensure the --xunit flag is placed before the test path in the command:

# Correct — flag before the test path
robot --xunit test-results/robot-junit.xml tests/

# Wrong — flag after the test path (treated as a test path)
robot tests/ --xunit test-results/robot-junit.xml

Also verify that the output directory exists:

mkdir -p test-results
robot --xunit test-results/robot-junit.xml tests/

If tests fail to run entirely (e.g., import errors), no output file will be generated. Check the console output for errors first.

Library not found

If Robot Framework reports Importing library 'SeleniumLibrary' failed, the required library is not installed. Install the library that your tests depend on:

# For SeleniumLibrary
pip install robotframework-seleniumlibrary

# For Browser (Playwright-based)
pip install robotframework-browser
rfbrowser init

# For RequestsLibrary (API testing)
pip install robotframework-requests

Verify the library is importable:

python -c "import SeleniumLibrary; print('OK')"

Keyword not found

If you see No keyword with name 'Some Keyword' found, check the import statements in your test file's *** Settings *** section:

*** Settings ***
Library    SeleniumLibrary          # For browser keywords
Library    RequestsLibrary          # For API keywords
Resource   ../resources/common.resource   # For custom keywords

Common causes:

  • The Library import is missing or misspelled
  • A Resource file path is incorrect (paths are relative to the test file)
  • A custom keyword is defined in a resource file that is not imported
  • The library is installed but the keyword name has changed between versions