Skip to content

Akanksha461/Robot_test_framework_python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 

Repository files navigation

Robot_test_framework_python

Introduction

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.

Robot Framework is operating system and application independent. The core framework is implemented using Python, supports both Python 2 and Python 3, and runs also on Jython (JVM), IronPython (.NET) and PyPy. For more information about Robot Framework and the ecosystem, see Robot framework

Installation

Preconditions

  • Python (Before installing Robot Framework, you need to install Python 2.5 or later)
  • Browser (I prefer Chrome )
  • Chromedriver (compatible with your chrome version)

Step1:- Install Robot Framework

            pip install robotframework

Step2:- Selenium2Library

            pip install robotframework-selenium2library

Step3:- Set Chromedriver path

            Copy the chromedriver file and paste it to usr/local/bin

Step4:- Set robot plugin in your IDE(Pycharm)

            Goto settings>plugin>browse repertoires> Search 'Robot Framework Support' over there.
            Add Robot Framework Support into your plugin.
            Restart the pycharm

Usage

To use SeleniumLibrary in Robot Framework tests, the library needs to first be imported using the Library setting as any other library. The library accepts some import time arguments, which are documented in the keyword documentation along with all the keywords provided by the library.

When using Robot Framework, it is generally recommended to write as easy-to-understand tests as possible. The keywords provided by SeleniumLibrary are pretty low level, though, and often require implementation specific arguments like element locators to be passed as arguments. It is thus typically a good idea to write tests using Robot Framework's higher level keywords that utilize SeleniumLibrary keywords internally. This is illustrated by the following example where SeleniumLibrary keywords like Input Text are primarily used by higher level keywords like Input Username.

*** Settings ***
Documentation    Suite description

Library  SeleniumLibrary


*** Variables ***
${Browser}  Chrome
${URL}  https://www.thetestingworld.com/testings/register.php

*** Test Cases ***
TC_001_Browser_Start_and_Close
    OPEN BROWSER  ${url}  ${browser}
    MAXIMIZE BROWSER WINDOW
    input text  name:fld_username  akanksha
    input text  xpath://input[@name="fld_email"]  ruhi461@gmail.com
    clear element text  name:fld_username
    select radio button  add_type  home
    select checkbox  name:terms
    click link  xpath://a[text()="Read Detail"]
    close browser 

Documentation

Robot Framework is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD). I have implemnted POM as design pattern to write my Test script.

Projcet Structure

  1. Requirements.txt- Requirement file defines all the basic requirenments which are used in this project.
  2. Keyword- Keyword folder contains base.robot file which contains all basic common keyword used in testcases.
  3. Locators- Locator file defines all the locators used in project.
  4. Testcases- From the name itself it is clear that this file defines all the testcases which are implemented.
  5. My_first_robot_script- This is the main file. By executing this file all the testcases will run accordingly.
  6. Varibale.py- User file defines all the data of user required in the project, like login etc.

Execution

After installations and with all other preconditions in place, you can run this project on the command line by using the robot command:

robot my_first_robot_script.robot 

Note:- Make sure you are in Testcase folder.

Tags:- Robot framework gives the feature of tags. For more details refer Robot Uesr Guide. Use tags while execution to run the categorized testcases, below is a sample for the same.

robot -i Regression my_first_robot_script.robot 

You get the results like log, output, log & screenshots(Incase of Failure) file when you execute your Test.

robot -d result Test/Testcases/my_first_robot_script.robot 

Releases

No releases published

Packages

No packages published

Languages