Robot Framework Automation

This example illustrates how to use the Shell Script Automation Host Feature to pull tests from GitHub. run Robot tests, parse the results, and automatically upload the test results to qTest Manager.

After the initial upload, the script allows you to schedule specific tests from qTest Manager, rerun selected tests, and update only those results on qTest.

The directions below are only samples but have been tested for accuracy. Use at your own risk. If there is a problem with an end result, make sure that the configuration has been established correctly. Issues with sample exercises are not covered by support.

Prerequisites

You will need to install the following applications to use the Robot Framework Automation Feature:

Tips for Prerequisite Set Up

Check PIP Installation

These instructions will work from Terminal (Mac. or Command Prompt (Windows.).

Note: if you are on Windows. make sure you run Command Prompt as an Administrator. If you are on Linux or mac, run these commands with sudo.

  1. Run this command to ensure the PIP install with Python was successful. It should output the pip version:

     pip --version  
  2. If PIP did not install, run the command below: python -m -ensurepip --default-pip Note: For more information on PIP installation, read here:

    https://packaging.python.org/tutorials/installing-packages/

  3. Once the PIP install is successful, run the following commands individually:

     pip install requests pip install urllib3
     pip install beautifulsoup4
     pip install lxml
    These commands will install the necessary modules required to run the Python scripts. The modules are used to send requests to the API, read json configuration files, and parse xml documents.

Windows

Ensure that all environment variables are set up correctly, before running the Automation Host script, specifically that the PATH variable is updated for Python, Robot, and Git.

Mac

  1. Use Homebrew to install Python and Robot. Steps for installing Homebrew can be found at https://brew.sh

  2. Once you install Homebrew, run the following command to get Python3:

    brew install python3
  3. Enter the following command to get Robot Framework:

     brew install robot-framework

Robot Automation Host Example from GitHub

https://github.com/sanjayjohn/shell-agent-samples/tree/master/AutomationHostExamples/automateRobot

Update Configuration File

Open the conf.json file and update with your personal information. Enter your own qTest URL and API Token found in your qTest Manager Environment.

  • git_url: The shell script uses the URL to clone a repository and send pull requests every time it runs if -git input is used.

  • local_repository: The folder containing the Test Cases. The shell script will use this to know where to run the Robot build. Make sure to place this folder in the same directory as the Python and shell scripts.

  • qTest_api_token: The token used to authorize the connection to qTest Manager.

  • qTest_url: The personal URL that is used to access QASymphony API.

For this example, we will be pulling Robot tests from BitBucket, which has a Robot demo located at https://bitbucket.org/robotframework/robotdemo/src/master/. For the git URL and local repository use the information shown below in the example configuration file. Make sure to use your own API Token and URL or the demo will not work.

Setup Automation

Follow these steps to set up your automated testing:

  1. Navigate to your Automation Host.

  2. Select the 'Add' button to add a new agent.

  3. In the New Agent window, enter the appropriate information for the following fields:

    • General Agent Information

      • Agent Name: Name

      • qTest Manager Project: Select your project

      • Agent Type: Choose Shell Agent

    • Test Scripts Information

      • Directory: The directory containing your scripts and shell agent (Directory where the scripts were cloned.)

      • Allocated Execution Time: Amount of time you expect the script to take to execute in minutes.

      • Kick-off Scripts: The file path to your shell script. This shell script takes in two inputs, one for using git and the second for updating your current test cycle.

        • To give the shell script permission to run, use the following command: Windows: run.bat Linux: chmod +x run.sh

        • Shell Script Inputs: -git Uses GitHub to clone a test case repository and send pull requests every time the shell script is run.

          -update Updates an existing test cycle or create a new test cycle if the first Test Run. (To create a new test cycle every time the script is run, do not use this argument.)

          Important: To run the shell agent, without using GitHub or updating the existing test cycle, do not include the parameters above in the Kick-off Scripts section.

  4. Save to close.

Run the Shell Script

To start the shell script, select the yellow icon in the action field which will upload all of the test cases to qTest Manager.

Schedule your Tests

  1. In Manager, select the Test Execution tab.

  2. Locate the Test Cycle in your project named "Robot Automated Tests."

  3. Select the Test Cycle, and it will display all of the tests that were run through the Robot Build along with their statuses.

  4. Click the checkboxes for the specific tests you would like to schedule and select Schedule from the "More" drop-down menu.

  5. In the Agent drop-down menu, select the Shell Agent and select OK.

  6. Once the tests are scheduled, you will need to go back to the Automation Host and select Poll Now to kick the Shell Agent off.

The shell script will only run the scheduled tests and upload those results to qTest Manager.