Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Test Automation using Selenium

(A Guide for Beginners)


1. Introduction
Selenium is an open-source tool that is used for
test automation. It is licensed under Apache
License 2.0. Selenium is a suite of tools that
helps in automating only web applications.
The purpose of this document is to describe
standards to be followed when designing and
developing framework code. This document will
help ensure consistency across the code,
resulting
in
increased
usability
and
maintainability of the developed code. This
document provides test automation guidelines to
leverage Selenium WebDriver features to foster
a
continuous,
consistent
and
standard
automation approach.

commands directly to the browser and retrieves


results.
Selenium Grid - Selenium Grid is a tool used to
run parallel tests across different machines and
different browsers simultaneously which results
in minimized execution time.

4. Framework Design and development

Pre-Requisite:
Ensure you have java installed in your
system.
Download Eclipse
Download Test-NG Plug-in and install it.

2. Scope
This tutorial is designed for software testing
professionals who would like to learn the basics
of Selenium through practical examples. The
tutorial contains enough ingredients to get you
started with Selenium from where you can take
yourself to higher levels of expertise.

3. Selenium Suit
Selenium
IDE
Selenium
Integrated
Development Environment (IDE) is a Firefox
plugin that lets testers to record their actions as
they follow the workflow that they need to test.
Selenium RC - Selenium Remote Control (RC)
was the flagship testing framework that allowed
more than simple browser actions and linear
execution. It makes use of the full power of
programming languages such as Java, C#, PHP,
Python, Ruby and PERL to create more complex
tests.
Selenium WebDriver - Selenium WebDriver is
the successor to Selenium RC which sends

Fig 1.0

Driver: Driver block is responsible to initilise all


the required objects to run the script. For
example: WebDriver Object or Properties object.
Pages:
Pages
are
representation
of
functionalities presented in AUT pages in form of
java classes.
Test Scenario: Test scenarios are actual test
cases written in TestNG framework.
Configuration Files: Configuration files, or config
files configure the initial settings for Automation
like URL for Applicaiton under Test (AUT), User
name, password etc.
Recovery: While executing the Selenium scripts,
we might get some Unexpected errors. In order
to recover the test and continue executing the
rest of the script from these unexpected errors,
Recovery Scenarios are used.
HTML reports: TestNG has the ability to generate
reports in HTML format and by default; it
generates a different type of report for its test
execution. This includes an HTML and an XML
report output. Without TestNG, Static HTML

report can also be created where the HTML tag


with information can be written in a HTML page.

Design and Implement Various Framework


Components
Testing the Framework Components and End
to End Testing
Training Resources on the Framework/Tool

5. Naming Conventions

Environment Setup
Training

Data
Type

Prefix

Example

Training Resources on the Framework/Tool

Boolean

bln

blnFlag

Integer

int

intCount

Long

lng

lngRowNumber

Double

dbl

dblWeight

Review Comments Incorporation

Object

obj

objCurrent

Single

sng

sngPosition

Script Execution Phase


Environment Setup

String

str

strCurPage

Array

arr

arrCellData

7. Functions

Variant

vnt

vntPropValue

Names:

User-Defined
Type

udt

udtTransaction

The function name should start with def followed


by the name of the function.

Scope

Prefix

Example

Global

gStrAppPath

Module-Level

mintRowCount

Static

svntFlag

Variable Passed by
Reference

rintValue

Variables Passed by
Values

vintValue

Script Development Phase


Script Creation
Script Debugging
Script Review

Result Analysis

When arguments are passed to the function, the


variable naming standards should indicate
whether it is passed by value or passed by
reference.
Example: def GetObject (strObjectname)

Local to the
Function

Header:
The function or procedure header should contain
the following:
Name of the project

None

strCurPage

The constant names should be initial capped with


underscores between words as shown in the
following example : gstrApplication_Path

6. Activities
The following major activities in each phase of
automation must be estimated.
Automation Initiation
Tool/Framework Feasibility Study
Environment Setup
POC
Framework Design/Implement

Name of the function


Name of the author
Description of the function/procedure
Date of creation
List of input parameters with their description
Name of the person modifying it
Date of modification
Example:

**************************************************
#Project Name : Test
#Function Name
: importdata.rb()
#Author : Open Source
#Description
: This function handles the
Suite Run, Object Repository, Keyword Driver
and creating Reports.

#Date of creation :
#Input Parameters:
#Name of person modifying: Tester #Date of
modification:

#Open the Object Repository Excel sheet


@@ObjBook=
@@excel.workbooks.open(@@Object_Rep)

**************************************************

8. Function Complexity
Framework code should be designed and
developed with minimal possible loops and
conditions for reduced complexity and enhanced
maintainability.

9. Function Structures
The following tips provide guidance for creating
easy-to-read and easy-to-maintain code.
Modularize the code for increased reusability
and reduced redundancy.

11.

General Guidelines

a.

Use an ampersand (&) for concatenating


strings instead of +.

b.

Set the objects to nothing for cleaning


the memory.

c.

Declare only one variable in a line.

d.

There should not be more than 80


characters per line.

e.

The code should be properly indented.

Code should be well-indented with tabs. (Tab


width should be 4).

f.

Values passed and returned to the functions


should use simple variables.

Declare variables using appropriate data


types.

g.

Avoid using the variant data type.

h.

Use procedures instead of functions if


there is no return value.

Reduce the use of global variables within the


function. The scope of the variable should be
decided based on the standards.

10.

Comment Standards

6.1

Framework Code Header Comments

The framework code header should contain the


following:

References
1. http://www.seleniumhq.org
2. http://www.qaautomation.net
3. http://mestachs.wordpress.com/2012/08/
13/selenium-best-practices

The copyright and proprietary information

Name of the framework code


Author of the code
Name of the reviewer
Date of creation
Version number

Every change to the framework code should be


documented in the modification history. A
modification history should contain the following:

6.2

Name of the person who changed the code


Date of change
Version
Changed function/event
Change description
Line Comments

Significant lines in the code should be provided


with inline comments to better explain the line of
code's purpose and make it easier for
subsequent developers to understand the code
faster and more thoroughly.
Example:

Vamsi Mohan is a research scholar in


Scope management, India. He is an
architect and consultant, managed end to
end
development
of
multinational
projects. An extensive experience in full
project lifecycle, software development,
application design and architecture,
documentation and project planning,
database design, systems analysis and
database optimization, conversion &
integration, technical support; testing and
implementation of various strategies in
BFSI, CRM and Telecom domains.PH919901261246.
E-mail:
vamsi.mohan@yahoo.co.in

You might also like