Robot Framework 01- Enviornment Setup in Linux and Running Test Scripts

Lokesh sharma
4 min readNov 15, 2019

--

Robot Framework is a generic open source automation framework for acceptance testing, acceptance test driven development (ATDD), and robotic process automation (RPA). It has easy-to-use tabular test data syntax and it utilizes the keyword-driven testing approach. Its testing capabilities can be extended by test libraries implemented either with Python or Java, and users can create new higher-level keywords from existing ones using the same syntax that is used for creating test cases.

  1. Installing Required Packages:
$ sudo apt-get install python3
$ sudo apt-get install python3-pip
$ sudo apt-get install python3-venv

2. Create Virtualenv and activate it:Virtualenv is a tool for creating isolated ‘virtual’ python environments.

$ python3 -m venv ./robot
$ source robot/bin/activate

3. Install Required Package through pip:

(robot)$ pip install --upgrade pip
(robot)$ pip install robotframework
(robot)$ pip install robotframework-seleniumlibrary
(robot)$ pip install selenium

4. Install Pycharm: open ubutu app store and install PyCharm CE

5. Install IntelliBot and Robot Framework Support plugin to Pycharm IDE

6. Select project interpreter from virtual enviornment

Press Ctrl+Alt+S in Pycharm it opens settings dialog then search from interpreter.

Select Virtual enviornment from path robot/bin/python3

7. Download and set Chromedriver/GeckoDriver

download chromedriver from https://chromedriver.chromium.org/

extract downloaded zip file and put chromedriver at robot/bin/Chromedriver location.

8. Writing Test Scripts:

00_Browser_Invoking.robot

*** Settings ***
Library
SeleniumLibrary #importing selenium library


*** Variables ***
${Browser}
Chrome #setting up browser to chrome
${URL} http://www.google.com

*** Test Cases ***
Open and Close Browser
#Test case name
Open Browser ${URL} ${Browser}
Close Browser

Run this test scipt by:

robot 00_Browser_Invoking.robot

This Test generate Output,Logs and Report Automatically.

Test report:

9. Second Test Script

01_First_Test_Case.robot

*** Settings ***
Library
SeleniumLibrary


*** Variables ***
${Browser}
Chrome
${URL} https://opensource-demo.orangehrmlive.com/


*** Test Cases ***
My First Test Case
Open Browser ${URL} ${Browser}
Maximize Browser Window
Input Text id:txtUsername wrong
Input Text name:txtPassword admin123
Clear Element Text id:txtUsername
Input Text id:txtUsername Admin
Click Button xpath://input[@type='submit']
Close Browser

Run this test scipt by:

robot 01_First_Test_Case.robot

Test Report:

10. Third Test Script:

02_Second_Test_Case.robot

*** Settings ***
Library
SeleniumLibrary


*** Variables ***
${Browser}
Chrome
${URL} https://www.facebook.com/


*** Test Cases ***
My Second Test Case
Open Browser ${URL} ${Browser}
Maximize Browser Window

Input Text name:firstname lokesh
Input Text xpath://input[@name='lastname'] sharma



Input Text xpath://input[@name='reg_email__'] lokesh@gmail.com
Input Text id:u_0_u lokesh@gmail.com
Input Text xpath://input[@name='reg_passwd__'] 1234567


Select From List By Index name:birthday_day 21
Select From List By Value id:month 10
Select From List By Label name:birthday_year 1994

Select Radio Button sex 2

Click Button name:websubmit

Close Browser

Run this test scipt by:

robot 02_Second_Test_Case.robot

Test Report:

Conclusion

In this tutorial we successfully created setup for our robot test enviornment. You now have the tools needed to get started building robot test framework.

--

--