Skip to content

Apurva8/DemoProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DemoProject

In this project, test scripts were written to automate some testing scenarios related to real time actions on different type of applications using Robot Framework.


Set-Up

  1. Python 3 interpreter
  2. Pycharm community edition for IDE

Automation Framework

In this project, Robot Framework was used as a Automation Framework to write the test scripts.

Robot Framework is a generic open source automation framework for acceptance testing, acceptance test driven development (ATDD), and robotic process automation (RPA). It has simple plain text syntax and it can be extended easily with libraries implemented using Python or Java. The core framework is implemented using Python and also runs on Jython (JVM) and IronPython (.NET).

The syntax for describing these test cases is based on a Keyword Driven Testing approach and a table format.

KEYWORD-DRIVEN TESTING is a scripting technique that uses data files to contain the keywords related to the application being tested. These keywords describe the set of actions that is required to perform a specific step.

  • Installation

    If Python and pip installed, run the below command in command prompt

    pip install --upgrade robotframework
    

    Install the package robotframework in project interpreter settings of current project on Pycharm.


Applications Used

In this project, the test scripts were written on the below type of applications


Libraries Used

In this project, below libraries are used:-

1. SeleniumLibrary

SeleniumLibrary is a web testing library for Robot Framework that utilizes the Selenium tool internally.

  • Installation

    For SeleniumLibrary installation, run the below command in command prompt

    pip install --upgrade robotframework
    

    Install the package robotframework-seleniumlibrary in project interpreter settings of current project on Pycharm.

    Install all the required browsers and operating system specific browser drivers used in the project. The general approach to install a browser driver is downloading a right driver, such as chromedriver for Chrome, and placing it into a directory that is in PATH.

    Add IntelliBot@seleniumlibrary plugin on Pycharm

  • How to use in project

  Library SeleniumLibrary

2. RequestsLibrary

RequestsLibrary is used to help in making the HTTP requests to a API.

  • Installation

    For RequestsLibrary installation, run the below command in command prompt

    pip install robotframework-requests
    

    Install the package robotframework-requests in project interpreter settings of current project on Pycharm.

  • How to use in project

  Library RequestsLibrary

3. Collections

Collections is Robot Framework's standard library that provides a set of keywords for handling Python lists and dictionaries. This library has keywords, for example, for modifying and getting values from lists and dictionaries (e.g. Append To List, Get From Dictionary) and for verifying their contents (e.g. Lists Should Be Equal, Dictionary Should Contain Value)

  • How to use in project

      Library Collections
    

Page Object Model

In this project, used to create the test scripts based on Page Object Model(POM).

Here all the locators related to the web page and user-defined keywords are created in Resource File. This file is imported to the test file and required keywords are used for the actions to get happened.


Data Driven Testing

In this project, approached a concept of Data Driven Testing while writing the test scripts.

DATA DRIVEN TESTING is a test automation framework that stores test data in a table or spreadsheet format. This allows automation engineers to have a single test script that can execute tests for all the test data in the table.

DataDriver is used/imported as Library but does not provide keywords which can be used in a test. DataDriver uses the Listener Interface Version 3 to manipulate the test cases and creates new test cases based on a Data-File that contains the data for Data-Driven Testing. These data file may be .csv , .xls or .xlsx files.

  • Installation

    For Data installation, run the below command in command prompt

    pip install --upgrade robotframework-datadriver
    

    Install the package robotframework-datadriver in project interpreter settings of current project on Pycharm.

    For excel file support of xls or xlsx file you need to install the extra XLS or the dependencies. It contains the dependencies of pandas, numpy and xlrd.

    pip install --upgrade robotframework-datadriver[XLS]
    
  • How to use in project

      Library     DataDriver     file=<<path of the data input file>>  sheet_name=<<sheet name>>
    

Packages Used

Below are other packages used in the project:-

1. robotframework-jsonlibrary

This package is a Robot Framework test library for manipulating JSON object.

  • Installation

    For robotframework-jsonlibrary installation, run the below command in command prompt

    pip install -U robotframework-jsonlibrary
    

    Install the package robotframework-jsonlibrary in project interpreter settings of current project on Pycharm.

2. robotframework-pabot

This package is a Robot Framework parallel test runner used for running the test scripts parallely at one time.

  • Installation

    For robotframework-pabot installation, run the below command in command prompt

    pip install -U robotframework-pabot
    

    Install the package robotframework-pabot in project interpreter settings of current project on Pycharm.

  • How to use in project

Following is the command can be used to run 3 processes parallely by giving its directory name alone where these test scripts are stored and also can store the resultant report files (log.html, output.xml and report.html) in a desired directory

 pabot --processes 3 --outputdir <<path of desired directory where the reports needs to be stored>> <<path of directory where the test scripts exists>>

Actions Used

Below were some actions used in the project

1. Waits

Following are different type of waits used in Robot Framework:

  • Sleep

Whereever we want to wait for sometime, add sleep before the statement. Bydefault the wait time is 0 seconds.

 sleep 3
  • Selenium Speed

This is used to add delay time for every statement in the test script. Bydefault the delay time is 0 seconds.

 set selenium speed 3 seconds
 
 get selenium speed
  • Selenium Timeout

This is used to add maximum time to wait until the given element is appeared on the webpage. Bydefault the maximum timeout is 5 seconds.

  set selenium timeout 10 seconds
  
  wait until page contains  <<text>>

This timeout is applicable only for that particular statement.

  • Implicit Wait

This is used to add maximum time to wait until the element got located with the given locator and this time is applicable to all web elements written in the test script.

Bydefault the wait time is 0 seconds.

  set selenium implicit wait 10 seconds

2. Mouse Over

Simulates hovering the mouse over the element locator.

  mouse over  link:<<locator>>
  
  click link  link:<<locator>>

3. Scrolling

Simulates scrolling on the webpage until particular element is found. Also helps in scrolling to the end of page and to the top of the page.

Following are examples to show how to use Execute Javacscript keyword for performing the scrolling in different scenarios

Scroll on webpage until certain element is located where its pixel number is used as a locator.

 execute javascript  window.scrollTo(0,1500)

Scroll until end of the webpage

 execute javascript  window.scrollTo(0,document.body.scrollHeight)

Scroll until top of the webpage

 execute javascript  window.scrollTo(0,-document.body.scrollHeight)

Scroll on webpage until certain element is located by using its locator.

 scroll element into view    xpath:<<locator>>

Robot Framework Metrics Report

Creates awesome HTML (dashboard view) report by parsing robotframework output.xml file

  • How it works
  1. Read output.xml file using robotframework API

  2. Get Suite, Test Case , Keyword , Status and Elapsed time values

  3. Convert data to html report using Beautifulsoup

  • Installation

    Install the package robotframework-metrics in project interpreter settings of current project on Pycharm.

  • How to use in project

    Following are the robotmetrics commands used to generate reports in different cases

    Case 1: No change in output.xml, log.html file name's and user is in same folder

    robotmetrics
    

    Case 2: RobotFramework Metrics Report metric-timestamp.html file will be created in current folder | -inputpath if specified

    Note: From v3.1.6 users can specify custom_report_name instead of metrics-timestamp.html

    robotmetrics -M regression_metrics.html
    

    Case 3: Customize specific custom logo in robotmetrics report by using --logo command line option

    robotmetrics --logo ../Apple-Logo.png -M regression_metrics.html
    
  • Help Option

    For more info on command line options use:

    robotmetrics --help
    

Embed a file

There is feasibility to embed links in robot framework log by different ways

1. Adding links via log

Instead of just putting a simple text we can also put a HTML Hyperlink.

 log   <a href="file://path of the data input file">Input Data File<a>    html=True

2. Adding links via free test suite metadata

We can use metadata in your test suites. Those metadata can contains external links and will add those links in output.xml and report.html files.

 *** Settings ***
 Metadata   Input Data File    <<file://path of the data input file>>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published