Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Robot Framework
  • SeleniumLibrary
  • Java (if using the Java variant of the "Robot Framework")

...

Examples

The full ATDD workflow

In this example we're going to validate a dummy website (provided in the GitHub repository), checking for valid and invalid logins. 

...

Code Block
titlelogin_tests/valid_login.robot
*** Settings ***
Documentation     A test suite with a single test for valid login.
...
...               This test has a workflow that is created using keywords in
...               the imported resource file.
Resource          resource.robot

*** Test Cases ***
Valid Login
    [Tags]  ROB-11  UI
    Open Browser To Login Page
    Input Username    demo
    Input Password    mode
    Submit Credentials
    Welcome Page Should Be Open
    [Teardown]    Close Browser



The previous Robot file use uses a common resource that contains some generic variables and some reusable "keywords" (i.e., steps).

...

Running the tests can be done from the command line or from within Jenkins (or any other CI tool); this will produce a XML based report (e.g. output.xml).



Importing results is as easy as submitting them to the REST API.with  with a POST request (e.g. curl), or by using one of the CI plugins available for free (e.g. Xray Jenkins plugin).

...

Within the execution screen details, accessible from each row, you can look at the Test Run details which include the overall result and also specifics about each keyword, including duration and status.


...


Running tests in parallel, against different environments

In this distinct and more evolved example we're going to run tests in parallel using "pabot"; we'll also take advantage of the Test Environments concept provided by Xray.

...

Code Block
languagebash
titlerun_parallel_and_import.sh
collapsetrue
#!/bin/bash

BROWSERS=(firefox chrome headlessff safari)
PROJECT=CALC
TESTPLAN=CALC-6424

i=1
for browser in ${BROWSERS[@]}; do
 curl -H "Content-Type: multipart/form-data" -u admin:admin -F "file=@pabot_results/output$i.xml" "http://192jiraserver.168example.56.102com/rest/raven/1.0/import/execution/robot?projectKey=$PROJECT&testPlanKey=$TESTPLAN&testEnvironments=$browser"
 i=$((i+1))
done

...

In Xray, at the Test Plan-level we can see the consolidated results and for each test case we may drill-down and see all the runs performed and in which enviromentenvironment/browser.

In this case, we have the total of 4 Test Executions (i.e. for safari, headlessff, chrome, firefox).

...