Versions Compared

Key

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

...

Code Block
titlelogin_tests/resource.robot
collapsetrue
*** Settings ***
Documentation     A resource file with reusable keywords and variables.
...
...               The system specific keywords created here form our own
...               domain specific language. They utilize keywords provided
...               by the imported SeleniumLibrary.
Library           SeleniumLibrary	run_on_failure=Capture Page Screenshot	screenshot_root_directory=EMBED

*** Variables ***
${SERVER}         192.168.56.1:7272
${BROWSER}        Firefox
${DELAY}          0
${VALID USER}     demo
${VALID PASSWORD}    mode
${LOGIN URL}      http://${SERVER}/
${WELCOME URL}    http://${SERVER}/welcome.html
${ERROR URL}      http://${SERVER}/error.html

*** Keywords ***
Open Browser To Login Page
    Open Browser    ${LOGIN URL}    ${BROWSER}
    Maximize Browser Window
    Set Selenium Speed    ${DELAY}
    Login Page Should Be Open

Login Page Should Be Open
    Title Should Be    Login Page

Go To Login Page
    Go To    ${LOGIN URL}
    Login Page Should Be Open

Input Username
    [Arguments]    ${username}
    Input Text    username_field    ${username}

Input Password
    [Arguments]    ${password}
    Input Text    password_field    ${password}

Submit Credentials
    Click Button    login_button

Welcome Page Should Be Open
    Location Should Be    ${WELCOME URL}
    Title Should Be    Welcome Page

...

A Test Execution will be created containing results for all test cases executed. In this case, you can see that it is also linked back to an existing Test Plan where you can track the consolidated results from multiple "iterations" (i.e. Test Executions).

Image Removed

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.

).

Image Added


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.


Image Added


Attaching screenshots

Attaching screenshots at the step level is possible by using the SeleniumLibrary RF library. A configuration must be provided to embed the screenshots on the output.xml report; it can also be configured to take screenshots automatically on failed steps.


Example of including and initializing the SeleniumLibrary:

Code Block
Library SeleniumLibrary run_on_failure=Capture Page Screenshot screenshot_root_directory=EMBED


In the GitHub repository, there's a buggy web server implementation. If tests are run against it, two of them will fail (i.e., the ones related with valid login).

Image Added


After importing the generated test report, we can see the screenshot in the Test Run details, in this case on the failed step.

Image AddedImage Removed

Running tests in parallel, against different environments

...

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

BROWSERS=(firefox chrome headlessfirefox safari)
PROJECT=ROB
TESTPLAN=ROB-22

token=$(curl -H "Content-Type: application/json" -X POST --data @"cloud_auth_prod.json" https://xray.cloud.xpand-itgetxray.comapp/api/v1v2/authenticate| tr -d '"')

i=1
for browser in ${BROWSERS[@]}; do
 curl -H "Content-Type: application/xml" -X POST -H "Authorization: Bearer $token"  --data @"pabot_results/output$i.xml" "https://xray.cloud.xpand-itgetxray.comapp/api/v1v2/import/execution/robot?projectKey=$PROJECT&testPlanKey=$TESTPLAN&testEnvironments=$browser"

 i=$((i+1))
done

...