Tutorial # 7 – Develop first test script

This tutorial focus on how to write first test automation script in Pycharm IDE and also explains about directories, Keywords, Variables and Settings.

No comments

Let’s develop first test script using Pycharm IDE

  • Open Pycharm IDE
  • Create a new Directory (File –> New –> Directory)
  • Enter Directory Name and Click ok
Create a Directory
  • Create a new robot file under created directory (Select Directory –> Right click and select New –> Click File).
  • Enter Robot file name as illustrated below (Robot files mush have ‘.robot‘ extension)

I will explain about key features required to create robot automation scripts.

Settings

  • Import libraries, Add Resources, Test SetUp and Teardown
    • For example, if you want import any library, you should use the following format as illustrated.

Syntax:

*** Settings ***

Library  SeleniumLibrary
Library OperatingSystem

Variables

  • This section is used to create variables, For example, you can create the variables for Browser, URL and Xpath.

Syntax:

*** Variables ***

${BROWSER}=         ie
${URL}= https://wordpress.com/
${GET_STARTED}= //a[@title='Get Started']

Test Cases

  • This represents a flow of specific test cases

Syntax:

*** Test Cases ***

Navigate to Login Page
Open WordPress

Keywords

  • Keywords are used to write a logic to perform specific task
    • For example, Enter UID, PWD and Click on Login button

Syntax:

*** Keywords ***

Open WordPress
Open Browser ${URL} ${BROWSER}
sleep 5s
#Maximize Browser Window
Wait Until Page Contains Element ${GET_STARTED} 5s
Close Browser
sleep 2s

Manual Test Case:

  • Open WordPress.com in IE Browser
  • Verify that WordPress home page is displayed

Automation Test Script
*** Settings ***
Library
SeleniumLibrary
Library OperatingSystem

*** Variables ***
${BROWSER}
= ie
${URL}= https://wordpress.com/
${GET_STARTED}= //a[@title=’Get Started’]

*** Test Cases ***
Navigate to Login Page
Open WordPress

*** Keywords ***

Open WordPress
Open Browser ${URL} ${BROWSER}
sleep 5s
#Maximize Browser Window
Wait Until Page Contains Element ${GET_STARTED} 5s
Close Browser
sleep 2s

Command to execute this script in Terminal

Execute this script through Pycharm terminal (To open Terminal : View –> Tools window –> Terminal)

Command:robot -d Results TestScripts\FirstScript.robot

Note:

  • -d results – will save the test results in Results directory
  • TestScripts\FirstScript.robot – path of the test script

Test Results

Test Results

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s