Wednesday, 17 May 2017

Working with different browser drivers.

To work with any browser, we need the executable driver for specific browsers. Here, I will explain about 3 major browsers & their executable driver that we are using in Windows environment.
1
Mozilla Firefox
Geckodriver.exe
System.setProperty(“webdriver.gecko.driver”,”/path/to/geckodriver.exe”)
2
Chrome
Chromedriver.exe
System.setProperty(“webdriver.chrome.driver”,”/path/to/chromedriver.exe”)
3
IE
IEDriverServer.exe
System.setProperty(“webdriver.ie.driver”,”/path/to/ IEDriverServer exe”)

Downloading WebDriver jars & configuring in eclipse.

The latest version of selenium web driver is 3.x. To use Selenium 3.0x the minimum requirement is JAVA8+. If we are using Selenium 3.x then you can use Mozilla latest version. If it’s failing to load Mozilla latest version then use latest – 1 version of Mozilla.
To download web driver jars, open the selenium official site (http://www.seleniumhq.org), go to Download section, Under JAVA click on download link to download the .zip file.
Once you download the .zip file, Extract the .zip file & keep it in your workspace directory. If you open the extracted folder then you can see lib folder where all the dependency jars are present.

Tuesday, 16 May 2017

Introduction to Selenium Web Driver.

Selenium-WebDriver was developed to better support dynamic web pages where elements of a page may change without the page itself being reloaded. WebDriver’s goal is to supply a well-designed object-oriented API that provides improved support for modern advanced web-app testing problems.
Selenium Web Driver was developed in such a way that, it can support Multiple Browsers, the code can be written in Multiple Languages & can be executed in Multiple Platforms.
            Selenium Webdriver Architecture:
            Selenium web driver works on 3 components as mentioned below:
Figure 4: Selenium Webdriver Architecture

Friday, 10 March 2017

Running multiple test suites through testng.xml file

Till now we have implemented the SignIn & Registration work flow & able to run the test suites individually. But practically we need to run all the test suites from a single file. To run multiple test suites, we can add the testns.xml file & will pass all the test suites inside the testng.xml file.
  • Download the testng.xml file from here.
  • Copy the testng.xml file inside src/test/resources.
  • Right click on testng.xml file > Run As > TestNG Suite & verify the result. It should run the SignIn Test 1st after completion it will open another browser & will execute the RegistrationTest as well.

Tuesday, 7 March 2017

Implement Test Case for Registration Workflow.

Let’s focus what we covered till now?
  1. Automated the Sign in workflow.
  2. Generated the logs.
  3. Added screen shots in logs file.
  4. Implemented the failure/skip of test case/test data.

Thursday, 2 March 2017

Running all test scenarios in same browser & implement failure/skip in SignInTest

For running all test scenarios in same browser, we need to do the below steps:
  1. Open browser – 1time.
  2.  Do the operation(s) – multiple time.
  3.  After operation come to the initial state.
  4. After completion of all operation close the browser.

Wednesday, 1 March 2017

Parameterizing the test cases

Till now we have discussed about the doLogin() method where we are passing the default username & password. But in our SignInTest there are multiple test scenarios with different combinations. So, we should write the script in such a way that it will run as per the scenarios. To achieve this, we can use @DataProvider for @Test method.


Implement Logging in Page Classes

In the previous post, we have created the extent reports & used in sign in test. Now, suppose we want to implement the logging in our page classes. For logging in page classes, we need to pass the ExtentReports & ExtentTest object into our page classes. We can follow the same steps as we did while passing the WebDriver object in page classes.

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.