Nothing Special   »   [go: up one dir, main page]

User Manual For Selenium Framework

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 20
At a glance
Powered by AI
The key takeaways from the document are that this is a Selenium framework that uses Excel sheets to write test cases. It has a keyword driven approach and uses a centralized object repository. The framework execution is faster than other tools like QTP and uses the Selenium library, so it is free to use.

The purpose of this framework is to provide a simple and easy to use way to automate test cases using Selenium even for non-technical users. It aims to reduce coding efforts and allow test cases to be written and maintained separately from the framework code itself.

The framework structure has different packages and classes that work together. The main classes are the Driver class, SeleniumDriver class, Engine class and ActionCaller class which work to fetch test data, execute actions and generate reports. It follows a clear layered architecture.

User Manual

For
Selenium Framework

Page 1
Contents

I. How to configure Selenium Framework in eclipse and


run your test case.
II. How to configure framework GUI in eclipse and run your
test case with the help of Framework GUI.
III. How to run your test case without eclipse.

Page 2
Selenium Framework

Page 3
How to configure Selenium Framework in eclipse and run
your test case through it??

Framework Introduction

This Excel based framework will let you write your test
cases in excel sheets.
Even a non technical guy whose hasnt have much
coding knowledge will be able to automate test cases.
With a small guidance a new user can start automating
test case.
This framework is keyword driven framework so you
just need to learn few keywords to automate your test
cases.
Because we are using a common centralize object
repository so change at one place will reflect in entire
project, thus it saves time and effort.
Because this framework is build over selenium, So
execution speed is comparatively faster than other
automation tools (QTP,TestComplete,CodedUI etc).
Free of cost.

Page 4
1.High Level Architecture Diagram

TestCase,ObjectRe
positoy and
TestData Excel

Selenium framework
reads test cases and
executes them
IE

Initiate Execution and provide test


case name, browser name to
Selenium Framework Interact with browser
F
Selenium engine to perform action
GUI to run on web page F
testcases Framework

Chrom
Call Report
engine to
generate report.

Html/X
Report ML
Engine report

Page 5
2.Class Level Data Flow Diagram

Driver call helper for


SeleniumDriver class inherits copying reporting
Driver class and gets WebDriver images and css to
and Element object result folder
TestCaseRe Driver

Engine call
TestcaseRead
er and gets
all the test SeleniumDriver
cases in a Engine call ActionCaller class class interect
MAP object and passes the test case
IE with browsers
data row by row

ActionCa SeleniumD FF

On the basic of data provided by Chro


Engine calls
engine class, ActionCaller calls
TestDataRead mee
appropriate function of Selenium SeleniumDriver Calls
er and gets
Driver Class. Report engine to
all the test
data in a MAP generate reports.
object
Html/Xml
TestDataRea
Reports

Page 6
3.Framework Structure

Page 7
1. Com.Driver : This package contains two classes.
a. Driver : The Driver class is the parent class which initialize
Driver, Element , ObjectRepository and all the global/protected
variables to be used during run time.
b. SeleniumDriver :
i. This class extends Driver class to get Driver and Element
object.
ii. This class contains various functions to perform action on
webpage and browser.

2. Com.Engine : This package consist of two classes


a. ActionCaller : This class calls functions of SeleniumDriver class
on the basic of action written in test case excel sheet.
b. Engine :
i. This class contains main function from where execution
starts.
ii. This class creates an object of SeleniumDriver class which
inturn initialize Driver,Element and all global objects.
iii. This class calls TestcaseReader and TestdataReader class
and get all the data in a Map
Map<String,List<Map<String,String>>> and then send data row
by row to ActionCaller class which in turn match the action
and call required function of SeleniumDriver class.

3. Com.Reader : This package consist of 3 classes


a. ObjectRepositoryReader :
i. This class reader object repository excel file and return
data in a Map Map<String,Map<String,String>>.
ii. Driver class calls this class during initialization.
b. TestCaseReader : This class read test case excel file and return
data in a Map Map<String,List<Map<String,String>>>.
c. TestDataReader : This class reads test data excel files and
return data in double dimension array format String[][].

Page 8
4. Com.Report : This package consist of 2 classes.
a. XmlReport : This class is used to create xml report of the
execution.
b. htmlReport : This class is used to generate HTML report of
execution.

5. Com.Utilities : This package contains only single class.


a. Helper : This class contains helper functions to be used by other
class such as
i. Copy reporting images to result folder ect.
ii. In future it will contain more helper functions if required.
b. Mail : This class is used to send execution summary mail to all
the recipients mentioned in config file.

6. Config : This folder contians a config file which contains various


configuration parameterse which must be set correctly before
executing a test case. The various parameters are :
a. ProjectPath : Path to the folder containing excel files (eg:
D:\Framework\ojt ).
b. ObjectRepositoryPath : Path to the objectRepository File (eg :
D:\Framework\ojt\Object_Repository.xlsx).
c. CommonSheetPath : Path to the common sheet file ( eg:
D:\Framework\ojt\Common.xlsx).
d. Browser : Name of the browser in which you want to run your
test case (ie,ff and chrome)
e. ReportDestination : Path where u want your report file to be
saved (eg: D:\Framework\ojt\report\report.html). Make sure the
path should actually exist.
f. FirefoxDriverPath : Path to your firefox driver (e.g :
c:\users\pankaj.bisht\Appdata\local\Mozilla firefox\firefox.exe)
g. ObjectHighlight : To hightlight the object during execution (Can
be True/False )
h. DateFormat : This parameter specify the default date format to
be use for entering date in textbox.
i. SenderUserId : Email Id of sender.
j. SenderPassword : Password of sender.
k. RecipientID : Email ids of all the recipients separated by ;.
l. Sendmail : This is a flag which accepts true or false to
activate email notification functionality.
m. TestcaseName: Name of the test case to be run.

Page 9
i. Multiple test case should be separated by ; (eg :
DP.FlightBooking.BookaFlight ; DP.CarBooking.BookaCar )
ii. Test case name should be start with sheet name followed
by dot (.) and then test case name.

7. Driver : This folder contains drivers for IE and Chrome browser.

8. Images : This folder contains images and css files for reporting
purpose. This folder gets copied to result destination folder when
execution starts.

9. Lib : This folder contains 3 sub folders

a. POI : contains poi jars, which provide libraries to read excel files.
b. JavaMail : Contains mail.jar to send mail.
c. Selenium : Contains selenium jars.

10. Testcases : Contains test cases excel sheet in which we are


writing our test cases.

4. Steps to Run Test case from Eclipse.


1. Put all jars under Lib folder in build path.
2. Open config file and set all parameters with correct data as per
your machine.
3. Since com.engine.Engine is the starting point of framework(i.e.
contains main function ) so place your mouse over it and right click-
> run as java application.

Page 10
FrameworkGUI

How to configure frameworkGUI in eclipse and run your


test case with the help of Framework GUI??

Page 11
1.HighLevel Architecture Diagram

Step 2 . After selecting Test cases, Browser,


Object Highlight etc from the GUI when user
click on run button, ButtonActionListner
class of Com.Form package calls
TestCaseNameR UpdateFile class and passes all the selected
testcases and other parameters to it.
Step 1. Call
TestcaseReader class
to get the names of all
the test cases and Com.Form- Step 3. On the basic of passed
display them in a tree Package parameters, UpdateFile updates
TestcaseName, Browser Name etc
parameter on config file of
SeleniumFramework.
Update

Step 4. After updating config file


of SeleniumFramework, Config file
ButtonActionListner class send a
call to com.engine.Engine Class
to start execution. Engin
e

Selenium

Page 12
2. FrameworkGUI Structure.

Page 13
1. Com.Form : This package contains 2 classes.
a. TestCaseNameReader : This class reads test case names from
excel.
b. UpdateFile : This class updates config file of
SeleniumFramework on the basis of parameters passed by
ButtonActionListener Class.

2. Form : This package contains 6 classes.


a. ButtonActionListener : This class passes user selected testcases,
browser name etc to UpdateFile class and display them on
console of GUI as well.
b. CheckNode : JbehaveInterface call this class to create new tree
nodes.
c. CheckRenderer : This class contains code to generate tree of
testcase name.
d. FrameworkInterface :
i. This class contains main function.
ii. set GUI (Height, Width and other dimensions) of Jframe .
iii. Call CheckNode and CheckRenderer classes to create test
case name tree.
e. Modelpanel : Contains code to display labels and radio button.

3. Properties : This folder contains a TestCaseRunner.Properties file which


contains various configuration parameterse which must be set correctly in
order to get correct details on GUI. The various parameters are :
a. ObjectRepositoryPath : Path to excel file which contains test case
names.(e.g : D:\\Framework\\OpenJaw\\ObjectRepository.xlsx)

4. Lib : Contains all POIs and Spring-Core jars

Page 14
3. Look and Feel of Framework GUI

4. Steps to Run Framework GUI Project.


1. Put all jar files in class path.
2. Open TestCaseRunner.Properties file and set all the parameters with
correct data as per your machine.
3. Since com.form.JbehaveInterface is the starting point of
FrameworkGUI (i.e contains main function ) so place your mouse
over it and right click-> run as java application.

Page 15
How to run your test case without
eclipse?

Page 16
Introduction

This framework will let u run create and run your test case
with eclipse. The following are the benefits of using it

1. Eclipse is no more need for test case creation and


execution.
2. Framework structure is simple and easy to
understand.
3. Framework Developers and automation tester can
work separately.
4. Easy to replace new jars with old one.

Page 17
1.High Level Architecture Diagram

TestCaseRunner Batch

Step 1. Step 2.Testcaserunner is the jar file of


Testcaserunner FrameworkGUI project. It takes parameters
batch file put all from config file (such as excel batch file
path, testcase sheet path ) to get the path of Test Case and
depending jars
(POI ) to batch file and excelsheet containing testcase Object
name and display them on GUI form. After
classpath and Repository
call selecting testcasename, Browser name and
TestCaseRunner other parameters on GUI form when user
clicks on Run button, it update config file
Step 5. Selenium framework reads
parameters with user seleceted data and
testcase and objectrepository file and
start execution as per the data
mentioned in the config file(i.e
TestCaseRunne Config browsername and testcasename)
r

Step 4. Selenium framework


fetches updated parameters IE
( such as
testcasename,Browser name
etc) from config file.
SeleniumFram F
Excel Batch
ework F

Chro
Step 3. Excel batch file put all
depending jars(Selenium & POI ) Step 7. Call Report me
to class path and call Selenium engine to generate
Framework Main() Function to report.
start test case execution

ReportEngin HTML/X
ML

Page 18
2.2. Framework Structure

Step 6. Interact with browser


engine to perform action on
web page

Page 19
1. Drivers : This folder contains drivers for IE and Chrome browsers
2. Html-dat : Contains images and css files for reporting.
3. Jar : This folder contains 3 subfolders
a. POI : contains Apache POI jars.
b. Selenium : contains selenium jars.
c. Spring : contains spring jar.
4. OpenJaw : this folder contains test case and object repository excel
files.
5. Report : this folder contains execution reports.
6. Config : This is a properties file which contains various parameters
as discussed above (5th point of Selenium framework section) .
Parameters under this file need to set before execution.
7. Excel bat : This is a batch file which put all dependent jars
(selenium, reporting and POI) on class path and run main method of
selenium framework jar.
8. SeleniumDriver : This is a jar file of Selenium Framework project.
9. TestcaseRunner Bat : This is a batch file which put all dependent
jars (POI and spring ) on classpath and run main method of
TestcaseRunner jar.
10. TestcaseRunner : This is a jar file of TestcaseRunner project.
11. htmlReport.xls : This file contains xls script to generate html
report from xml file.

3.Steps to Run Test Cases.


Pre-Condition : you should have this framework folder and java should
be installed in your system.

1. Update your config file with correct data as per your machine
requirements.
2. Double click on TestcaseRunner batch.
3. This will open a GUI form, select your test case, browser name and
other stuff and click on run button.
4. This will start executing your test case on selected browser.

Page 20

You might also like