Tuesday, 28 February 2017

Generate Extent Reports in SignInTest

In the previous post, we got some idea about the extent reports. Here we will implement the extent report in our test cases & will verify the report.
As of now I will introduce the extent report only for SignInTest & in next post onwards I will implement the same for other tests as well.
To generate the report, follow the steps below:

Adding Extent Reports to generate the test reports

In software testing the main important part is reporting where user can able to get the status of any test cases. If we are running the test cases through TestNG or Junit, then we get some html reports which are not so good. To avoid the same, we can use XSLT reports which have the reports generated in PIE chart but we can’t get the complete information about the tests. For better understandings, we can keep the test logs & the status in a single html file & the same can be achieved by using Extent Reports.

Monday, 27 February 2017

Add BaseTest class file to keep all the common functionality of Test Cases & remove hard coding

As you have seen in SignTest there are some code which is used to Open Browser & navigate to the URL. Similarly, there might be multiple test cases like RegistrationTest, CartTest etc. So instead of writing the same code to Open Browser & navigate to URL, we will add a BaseTest.java class file in our test cases & every test cases will extend to that BaseTest class.

Friday, 24 February 2017

Creating the Base Page & Top Menu classes

Let’s add a base page class which will contain all the reusability methods & each page class will extend the base class.
To create a BasePage.java, Right Click on com.demo.pom.pages > Click on New > Class > Insert the name as BasePage

Thursday, 23 February 2017

Add web driver code, page objects & share the same web driver across pages

In previous post, we had discussed about the challenges. Let’s 1st look onto how can we share same driver object across pages?
The answer to the above question is, we can implement Page Factory design patter in our project. In Page Factory Design pattern, we have a method, PageFactory.initElements(driver, LunchPage.class)
The above method will initialize the driver object in LunchPage class internally.
Let’s change the code as below & after that will explain the code overview:

Wednesday, 22 February 2017

Update the page class files.

For page classes, we have already defined the package & also added the class files for each page.
Let’s test with some basic data like printing the data in methods. Let’s take an example of SignInTest.
As previously mentioned, to sign in we need to lunch the browser > navigate to sign in page > insert valid details & click on signin button > It should navigate to MyAccountPage.

Add .xls File Reading Utility in Framework

In the previous post, we have added the required excel data sheet. Here, we will discuss how can we read data from excel sheet using apache POI.
For reading the excel data we should require the apache POI dependencies in our pom.xml file. Please check the below dependencies in pom.xml file:

Tuesday, 21 February 2017

Add Required .xls Files of Data

Till now we have created the project structure & added the required class files in the project. Here, we will discuss about the required DataSheet.xlsx file & the template for the DataSheet.
Download the attached DataSheet.xlsx template from here & place the file in src/test/resources directory.

Monday, 20 February 2017

Creating Required Class Files for Pages & Test Cases

Before we proceed with creating the class files, let’s take an example of a site  http://automationpractice.com/, where we will automate the Registration Flow, Login Flow, Add Product to Cart Flow.
Registration Flow:
To do the registration we need to open the browser, navigate to sign in page, insert email address, click on create account button, fill all the details, click on Register. If all are valid then it will navigate to my account page.
Please check the below flow diagram for registration work flow:

Sunday, 19 February 2017

Creating the package structures for the project

In the previous post we have imported the maven project into eclipse workspace & updated the pom.xml file by adding the required dependencies. In this post I will discuss about the different packages & their uses. Please follow the steps below:

Saturday, 18 February 2017

Adding dependencies in pom.xml file.

In the previous post, we have created the mvn project & converted into an eclipse project. In this step we will import the existing project into eclipse work-space & will update the default pom.xml file, will add the required dependencies into the pom.xml file.
Please follow the below steps to import the project into workspace:

Create Maven Project for Framework & converting into eclipse project

How to create a maven project through command line?

Prerequisites:
The system should be configured with mvn, eclipse & JDK.

Let's start creating the Maven project through command line. Please follow the steps below to create a maven project & converting the maven project into an eclipse project.

Configure Maven in your System

How to Setup/Install Maven Class path Variable on Windows

Step 1: Download apache maven from the link(binary) >  Extract the .zip file in "C:\Program Files" directory.
Step 2: Open System Variable pop up (Right Click on My Computer > Properties > Click on Advanced System Settings > Click on Environment Variables

Friday, 17 February 2017

Step by Step Guide to create POM Framework with Pagefactory

Selenium Page Object Model with Page Factory

POM:

  • Page Object is a Design Pattern which has become popular in test automation for enhancing test maintenance and reducing code duplication.
  • A page object is an object-oriented class that serves as an interface to a page of your AUT. The tests then use the methods of this page object class whenever they need to interact with the UI of that page.
  • The benefit is that if the UI changes for the page, the tests themselves don’t need to change, only the code within the page object needs to change. Subsequently all changes to support that new UI are located in one place.