Friday, July 5, 2019

How to select a suitable Automation Framework?



There are many frameworks available in the market. Before jumping to decide which framework to use or select. Let's see a few questions where people ask on the open forum

Which framework is suitable for branding advertising portals?
Which framework I should use for an e-commerce website?
Which technology I should use to build a framework for a logistic website?
and many more questions...

So, Let's see what are the framework are available in the market

  • Linear testing framework 
  • Modular driven testing framework
  • Data-Driven testing framework
  • Keyword Driver testing framework
  • Hybrid testing framework
  • Behavior-driven development testing framework

What is Linear testing Framework?

The linear testing framework is created in such a way that the test developer writes the code in small methods for each feature and execute it individually. This is a very basic level of the framework and mostly used in the record and play features.  

What is Modular driven testing framework?
In this framework, the test developer creates a small script for each module of the application and call them based on functionality. e.g Login script, Register user script, and Cash Deposit script. These modules are independent of each other and can be called as per functionality flow. In this framework, objects and methods are written in the class file and each class file represents a module of the application. 

What is a data-driven testing framework?
In this framework, the test developer creates a script separately and pass the data from the external file. That means if test developer whats to change the data set then test developer should not change the code or compile the code for new sets of data. Script and data manage separately.  Now the question is If we use data file in the linear and modular driven framework then it won't become data-driven? I would say, Yes, To avoid this you set the data in the code itself. These both frameworks used when you have fewer data and small scale application.

What is Keyword driven testing framework?
In this framework, the test developer defines a keyword to perform actions. e.g Create keyword call CLICK_ON which actually click on the given element. The main feature is your script flow or methods are called based on keyword created. Table creation concept is used while creating this framework.

What is Hybrid testing framework?
When the test developer mixes any two or more frameworks then it becomes Hybrid testing framework. Why test developer do this? For big project and complex scripting, it required to choose Hybrid testing framework. 


What is Behavior-driven development testing framework?
BDD is known as Behavior-Driven Development testing framework. It is very famous when management or Business Analyst involved in the automation result. Report generated in pure English language where BA or management can take a decision on product quality.  


Now, Coming to the main question "How to select a suitable framework Framework?" Framework design or selection should not be done on the product domain. It always creates based on the following criteria:

  • Complexing to the application to test
  • Purpose of automation testing
  • Platform Coverage (Single platform execution or multiple platform executions)
  • The user of the test automation report
  • Resource availability
  • Technical Skill 
  • Test Data Coverage
  • Deadline
Hope this will help you to select a suitable framework for your next automation project.


Friday, June 8, 2018

Create Selenium WebDriver using Java Factory Pattern

Hi Friends,

In Factory pattern, we create an object without exposing the code to the client and refer to a newly created object using a common interface.

This is widely used java pattern for creating the object. 

Here is the UML diagram for creating the webDriver object. 




Click here to download the code from GitHub repo

Note: This is just an idea. Future enhancement can be done based on requirement. 


Thursday, June 7, 2018

Create Selenium WebDriver object using Singleton Java pattern

Hi Friends,

You must be knowing about the java patterns and it's advantage. In this post, I am going to create webDriver object using Singleton java pattern.

Singleton means to define a class that has only one instance and provides a global point of access to it.

Singleton class :


public class WebDriverSingleton {

private static WebDriver driver;
private static WebElement element;

private WebDriverSingleton() {
}

public static void initDriverInstance(Browsers browserName) {
 // code for init driver object
}

public static void openURL(String url){
// open url code
}
public static void quit() {
// code for quit driver
}

public static WebElement findElement(Locator locator, String value) {
// code for findElement 
}

// add all the other required method here
}


Test class :

public class Test_1 {
@BeforeClass
public void Setup() {
WebDriverSingleton.initDriverInstance(Browsers.CHROME);
WebDriverSingleton.openURL("http://newtours.demoaut.com");
}
@Test
public void TestCase_1() {
WebDriverSingleton.findElement(Locator.NAME, "userName").sendKeys("testuser");
WebDriverSingleton.findElement(Locator.NAME, "password").sendKeys("testpassword");
WebDriverSingleton.findElement(Locator.NAME, "login").click();
}
@AfterClass
public void killDriver() {
WebDriverSingleton.quit();
}
}

Click Here to Download code from github