How to configure Selenium Framework in eclipse and run your test

advertisement
User Manual
For
Selenium Framework
Page 1
Contents
I.
II.
III.
How to configure Selenium Framework in eclipse and run your test
case.
How to configure framework GUI in eclipse and run your test case
with the help of Framework GUI.
How to run your test case without eclipse.
Page 2
Selenium Framework
How to configure Selenium Framework in eclipse and run your test case through
it??
Page 3
Framework Introduction
 This Excel based framework will let you write your test cases in excel
sheets.
 Even a non technical guy whose hasn’t 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,ObjectRepositoy
and TestData Excel Files
Selenium framework reads
test cases and executes
them
IE
Initiate Execution and provide test case name,
browser name to Selenium Framework
GUI to run testcases
Selenium Framework
Interact with browser engine
to perform action on web page
Chrome
Call Report engine to
generate report.
Report Engine
Html/XML
report
Page 5
FF
2. Class Level Data Flow Diagram
Driver call helper for
copying reporting images
and css to result folder
SeleniumDriver class inherits Driver class
and gets WebDriver and Element object
TestCaseReader
Engine call
TestcaseReader
and gets all the
test cases in a
MAP object
Driver
Engine call ActionCaller class and
passes the test case data row by row
Engine
ActionCaller
TestDataReader
SeleniumDriver
class interect with
browsers
IE
SeleniumDriver
On the basic of data provided by engine
class, ActionCaller calls appropriate
function of Selenium Driver Class.
Engine calls
TestDataReader
and gets all the
test data in a
MAP object
Helper
FF
Chrome
e
SeleniumDriver Calls
Report engine to generate
reports.
Report
Html/Xml 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.
i. Multiple test case should be separated by “;” (eg :
DP.FlightBooking.BookaFlight ; DP.CarBooking.BookaCar )
Page 9
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
TestCaseNameReader
Step 1. Call TestcaseReader
class to get the names of all
the test cases and display
them in a tree structure
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 UpdateFile class and passes all the selected
testcases and other parameters to it.
Com.Form-Package
Step 3. On the basic of passed parameters,
UpdateFile updates TestcaseName, Browser
Name etc parameter on config file of
SeleniumFramework.
UpdateFile
Step 4. After updating config file of
SeleniumFramework, ButtonActionListner
class send a call to com.engine.Engine Class
to start execution.
Config file
Engine
Selenium Framework
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 POI’s 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.
Testcaserunner batch
file put all depending
jars (POI ) to
classpath and call
TestCaseRunner
Main() Function
2.
Step 2.Testcaserunner is the jar file of FrameworkGUI
project. It takes parameters from config file (such as
excel batch file path, testcase sheet path ) to get the
path of batch file and excelsheet containing testcase
name and display them on GUI form. After selecting
testcasename, Browser name and other parameters on
GUI form when user clicks on Run button, it update
config file parameters with user seleceted data and
then finally send command to run Excel batch file.
Test Case and
Object Repository
Excel Files
Step 5. Selenium framework reads testcase and
objectrepository file and start execution as per
the data mentioned in the config file(i.e
browsername and testcasename)
TestCaseRunner
Config File
Project Jar
Step 4. Selenium framework fetches
updated parameters ( such as
testcasename,Browser name etc)
from config file.
IE
SeleniumFramework
Project Jar
Excel Batch
Step 3. Excel batch file put all depending
jars(Selenium & POI ) to class path and
call Selenium Framework Main()
Function to start test case execution
Step 6. Interact with browser engine
to perform action on web page
Chrome
Step 7. Call Report engine to
generate report.
ReportEngine Jar
HTML/XML
Reports
Page 18
FF
2. Framework Structure
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
Download