Selenium

Framework:

Hybrid Framework Details:-
The hybrid framework created using Selenium Web Driver and TestNG framework which contains mainly 3 folders, those are
1. Objects
2. Operation
3. Test Cases


1.  Objects:-
Objects folder contains Property files, which are used to identify the objects in web pages.
Property file contains two elements,
1. Object name
2. Object Property

Ø  How to create Property File:

Right click on the Folder in Eclipse
Go to New
Click On File
Now name the file with ending extension as .properties
Ex: myPropertyFile.properties
Now click Finish  button.

Note :- Each Property file name should be meaningful  on corresponding Web page ex:  for google.com home page , name the property file as googleHomePage.properties

Ø  How to assign Object Properties in Properties File:

Object Name: object name is uniquely assigned by the user , so it can be used in test cases to perform operations on the particular object, like click, Select, GetText, SetText etc…

Object Property: object property can be captured by using Firebug in Firefox Browser , property examples- ID, XPATH, CSS, Name etc..



Bellow is the Example of how to create a Object Property in a Property File: -

Here we spied the Google images search box , you can see the search box properties in left side of the image.
You can use ID which is sb_ifc0 as a property to identify the search box.

GoogleImageSearchBox=sb_ifc0

As shown above “GoogleImageSearchBox” is the Object Name and “sb_ifc0” is the property of the Object.






2.   Operation:

Operation Folder contains 3 files, those are
1. Operations.Java
2. ReadObject.java
3. CommonLibrary.Java

2(1). CommonLibrary.Java: - Commonlibrary.java contains basic functions which can be used while creating test cases, like
1.CreateBrowser
2. uniqueNumber
3. takeScreenShot
4. takeObjectScreenShot

2(2). ReadObject.java:-main objective of  readObject.java is loads the Object properties from the given Properties file , so it can be used to identify the objects of web page while performing the operations.
2(3). Operations.Java:- operation.java holds very important role in this framework. it  takes inputs from ReadObject.java ( Loads all objects from the File) and Test Cases.
 Based on given inputs it Finds the object and Performs the actions on that particular object, like Click, SetText, GetText, Select, etc. finally if everything goes well then it reports pass or else it will report Fail with exception details with Screenshot of the browser.








3.  Test Cases Or Test Suites:

Test Cases package is container for created test cases.

3(1). How to create Test Cases:


1.      Create the testing class with the test name.
2.      Create a method having meaningful name.
3.      Create instances of common library and operations
Ex:       CommonLibrary libraryFunctions=new CommonLibrary();
 WebDriver driver=libraryFunctions.createBrowser();
 Operations operation = new Operations(driver);
4.      Perform the operations on web page objects
Ex: operation.GoToURL( “googleHomePage”,”url”);

In the above example value “googleHomePage” is the File name and Url is the ObjectName which is specified in th “googleHomePage.properties” file

5.      After creating Test Case add it to testing.XML file
EX:
<test name="googleHomePage_Test">
    <classes>
      <class name="testCases.GoogleHomePage"/>
  </classes>
</test>

In the above example name=”googleHomePage_Test” is the test name
In the classes tags section you have to mention the Class name of the Test with Package name.

6.      Use Test Annotation for Various Test Operations.
7.      Every test must End with  calling the Method  operation.reportErrors();

Note: If operation.reportErrors() is not called then failed test cases will be marked as passed.


No comments:

Post a Comment