Skip to content

Latest commit

 

History

History
166 lines (130 loc) · 5.96 KB

readme.md

File metadata and controls

166 lines (130 loc) · 5.96 KB

RPA Challenge

  1. The goal of this challenge is to create a workflow that will input data from a spreadsheet into the form fields on the screen.
  2. Beware! The fields will change position on the screen after every submission throughout 10 rounds thus the workflow must correctly identify where each spreadsheet record must be typed every time.
  3. The actual countdown of the challenge will begin once you click the Start button until then you may submit the form as many times as you wish without receiving penalties.

Topics -> robotframework, python, rpa-challenge, automation

Preview Link -> RpaChallenge

What We are going to do?

  1. Starting the RpaChallenge Website
  2. Simply input the data from excel sheet
  3. Finding the suitable selectors and entering the data.
### Understanding Some Important Concepts **What is Robot Framework?** Robot Framework is a generic open source automation framework. It can be used for test automation and robotic process automation (RPA). Read more on robot framework website

We will be using the css selectors.

But, What are selectors/locators?

A CSS Selector is a combination of an element selector and a value which identifies the web element within a web page.

The choice of locator depends largely on your Application Under Test

Id An element’s id in XPATH is defined using: “[@id='example']” and in CSS using: “#” - ID's must be unique within the DOM. Examples:

XPath: //div[@id='example']
CSS: #example

Element Type The previous example showed //div in the xpath. That is the element type, which could be input for a text box or button, img for an image, or "a" for a link.

Xpath: //input or
Css: =input

Direct Child HTML pages are structured like XML, with children nested inside of parents. If you can locate, for example, the first link within a div, you can construct a string to reach it. A direct child in XPATH is defined by the use of a “/“, while on CSS, it’s defined using “>”. Examples:

XPath: //div/a
CSS: div > a

Child or Sub-Child Writing nested divs can get tiring - and result in code that is brittle. Sometimes you expect the code to change, or want to skip layers. If an element could be inside another or one of its children, it’s defined in XPATH using “//” and in CSS just by a whitespace. Examples:

XPath: //div//a
CSS: div a

Class For classes, things are pretty similar in XPATH: “[@class='example']” while in CSS it’s just “.” Examples:

XPath: //div[@class='example']
CSS: .example

Libraries Required :-

  1. robotframework => It is main framework which runs all the code under the keyword.
  2. robotframework-seleniumlibrary => It is responsible for managing the browser
  3. robotframework-datadriver => It will take the data from excel to the program

So, How to install them ? Run the following commands in python shell

pip install robotframework
pip install robotframework-seleniumlibrary
pip install robotframework-datadriver

Step 1 => Starting the RpaChallenge Website (RpaResource.robot)

It will open the browser with the help of selenium webdriver It will then load the Rpa challenge website and start the test.

*** Settings ***
Library  SeleniumLibrary

*** Variables ***
${browser}  chrome
${url}      http://www.rpachallenge.com/

*** Keywords ***
StartTheTestCase
Open browser    ${url}  ${browser}
Page Should Contain Element     xpath://button[contains(text(),"Start")]
click element   xpath://button[contains(text(),"Start")]

Step 2 -> Simply input the data from excel sheet (data_entry.robot)

We will use the robotframework-data driver to load the data from the excel file

*** Settings ***
Library  SeleniumLibrary
Library  DataDriver     ../TestData/challenge.xlsx
Resource    ../Resource/RpaResource.robot
Suite Setup     StartTheTestCase
Test Template   EnterTheData

*** Variables ***

*** Test Cases ***
EnterTheData with   ${First}     ${Last}     ${Company}  ${Role}     ${Address}  ${Email}    ${Phone}

Step 3 -> Finding the suitable selectors and entering the data (data_entry.robot)

We will locate the element with the help to css selector and then enters the required data and finishes the task.

*** Settings ***
Library  SeleniumLibrary
Library  DataDriver     ../TestData/challenge.xlsx
Resource    ../Resource/RpaResource.robot
Suite Setup     StartTheTestCase
Test Template   EnterTheData

*** Variables ***

*** Test Cases ***
EnterTheData with   ${First}     ${Last}     ${Company}  ${Role}     ${Address}  ${Email}    ${Phone}

*** Keywords ***
EnterTheData
[Arguments]  ${First}       ${Last}     ${Company}  ${Role}     ${Address}  ${Email}    ${Phone}
input text   xpath://input[@ng-reflect-name="labelPhone"]       ${Phone}
input text   xpath://input[@ng-reflect-name="labelCompanyName"]       ${Company}
input text   xpath://input[@ng-reflect-name="labelRole"]       ${Role}
input text   xpath://input[@ng-reflect-name="labelAddress"]       ${Address}
input text   xpath://input[@ng-reflect-name="labelEmail"]       ${Email}
input text   xpath://input[@ng-reflect-name="labelFirstName"]       ${First}
input text   xpath://input[@ng-reflect-name="labelLastName"]       ${Last}
click element   xpath://input[@type="submit"]

How to run

  1. Install all the required libraries by : -

    pip install -r requirements.txt
    
  2. Then you need to install the selenium web driver in your system. You can follow this link Youtube

  3. Run the following command

    robot TestCases/data_entry.robot
    

Web Preview / Output