Skip to content

Zahid-Automate/RobotFramework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Robot Framework Demo

Robot Framework is a generic open source test automation framework. In addition to introducing Robot Framework test data syntax, this demo shows how to execute test cases, how generated reports and logs look like, and how to extend the framework with custom test libraries.

Contents:

Downloading package

To get the project, you can either download and extract the latest package from the GitHub or checkout the source code directly. As a result you get **RobotFramework** directory with several files.

Example test cases, test library used by a robo project, and generated results are available also online. Therefore, you do not need to download the project if you are not interested in running it yourself.

Test cases

This project contains the below test cases
1. Login into a website
2. Verifying Input Box
3. Selecting Radio buttons and Checking/Unchecking of Checkboxes
4. Selecting Drop Down values
5. Using Implicit wait keyword **set selenium implicit wait** for a Registration Page on a website
6. Command to run only test cases with Tag regression
robot --include=regression .\TestCases\CredentialTest.robot

  Command to exclude test cases with Tag regression  

robot -e regression .\TestCases\Credentials.robot

  Command to run test cases with both Tags i.e sanity and regression

robot -i sanity -i regression .\TestCases\Credentials.robot
  1. Reading data from a complex Json file and passing the same onto a website

Python based debugging in Robot Framework

Import the DebugLibrary.py file present in this project root folder into your test case
Use Suite Tear down keyword and a keyword Teardown Actions as shown below
imageimage

Make sure to include the set breakpoint in your test case to activate the Python Debugger (Pdb)
image

Use the below command in the terminal, to run the test cases in Debug Mode

$Env:ROBOT_DEBUG = 'TRUE'; robot  .\TestCases\ReadingDataFromJson.robot

Set the value of the variable to the desired value at run time

BuiltIn().set_local_variable("{firstName}", "Superman") 

In order to get the value of the variables during run time use below command in Pdb

BuiltIn().get_variable_value("${firstName}")

Screen-shot of how the value will look like after runtime modification of the variable image

image

When pause for debug keyword is used , we get to see the below pop-up, where the execution gets stopped
image

Printing the console logs to a txt file


robot .\TestCases\Credentials.robot > results/console-output.txt

The above will create a txt log file which has all the contents of Log to Console key word present in your test case into a results directly

Re-run the failed test cases and Merge the rerun results with the Previously failed test result


robot --output original.xml tests                          # first execute all tests
robot --rerunfailed original.xml --output rerun.xml tests  # then re-execute failing
rebot --merge original.xml rerun.xml                       # finally merge results
image


Re-run Failed Tests.html

Generated results

After running tests, you will get report and log in HTML format. Example files are also visible online in case you are not interested in running the demo yourself. Notice that one of the test has failed on purpose to show how failures look like.


FirstReport.html
Firstlog.html


ReportWithFailures.html
LogWithFailures.html

Preconditions

A precondition for running the tests is having Robot Framework installed. It is most commonly used on Python but it works also with Jython (JVM) and IronPython (.NET). Robot Framework installation instructions cover installation procedure in detail. People already familiar with installing Python packages and having pip package manager installed, can simply run the following command:

pip install robotframework  


Robot Framework 3.0 and newer support Python 3 in addition to Python 2.

About

Robot framework automation using Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published