Introduction: Framework Overview
To build a reusable and maintainable automation system, a sound framework or guideline is required that properly instructs test case structure, test case execution process, code structure, test data process, handling object repository etc. Various automation frameworks available and implementing such framework is multi-phase process. Among those frameworks, most used are Functional or Procedural framework, Data Driven Framework, Business Process Framework, Keyword Driven Framework etc. In my project, I would suggest to implement Hybrid level framework that is the combination of above different frameworks. In Functional or Procedural framework, common jobs inside the scripts are grouped into methods. The main advantage of this framework is easy to develop test scenarios with reusable libraries . A driver main-script calls those functions and constructs test scenarios. My Test Automation framework will implement this Procedural framework incorporated with Data Driven Framework . In Data Driven framework, test data are read from external files or database and loaded into inside the scripts. The benefit of using this framework is that the test data won’t be affected for any modifications of the scripts and it is possible for several execution of test scripts with different groups of test data. My Test Automation framework will implement this Data-Driven Framework. In Business Process framework, large business process are divided into small Application Modules. Various test cases or test scripts will use or call these small Application Module. My Test Automation framework will implement this Business Process framework. Another notable framework is Keyword Driven framework or Table Driven framework. This is independent of test automation tool. A Table is constructed with Objects, Actions to be performed which is the Keyword and with related arguments. A set of driving scripts will read each row as a step, execute the row or step based on the keyword. The test cases can be added or changed just by altering the table row but building complete driver scripts needs high level expertise and initial investment in terms of time and budget can be excessive for some project. My Test Automation framework will not consider Keyword Driven framework.
So in summary, my Test Automation framework will implement Hybrid Data Driven framework that consist of Functional or Procedural framework, Data Driven Framework and Business Process framework. If we afford the license cost, UFT is very good automation tool to proceed with. HP UFT together with open source Selenium WebDriver could be the best combination for any type of project. Selenium is open source and it does not require license. Selenium has the option of using wide range of IDEs and it supports multiple browser and programming languages. Selenium-Grid can be used to run simultaneous tests on different machines using different browsers and different operating systems in parallel which makes it good tool for cloud-based testing architectures and services. Initial consideration of my Test Automation framework would be to implement Selenium Page Object Model, TestNG framework, Logging framework along with satisfying above mentioned hybrid data driven framework. It is possible to run selenium scripts using UFT LeanFT.
Technical Solution: Selenium Test Automation Framework
• The Selenium is an open source tool for driving browsers. The part of the Selenium suite of tools that will be used is the WebDriver API. This API drives a browser natively as a user would and is part of the Selenium 2.0 suite. Selenium WebDriver makes direct calls to the browser using each browser’s native support for automation. Each browser has a separate tailored driver and whilst the basic capabilities are the same there are differences in what can be accomplished. To start an automation session via the WebDriver API we simply instantiate the specific browser driver.
• Basic principle of my Selenium Automation system is to ensuring the initialisation of the WebDriver to identifying objects, this is done by encapsulating the common behaviour in a generic WebTest base class that all Test classes inherit from. Once a page is loaded there also common capabilities and behaviours that can be abstracted away. Finally the definition of each page and the interaction with the elements on the page can also be abstracted away to make the test scenarios clean. The overarching principle to this approach is to guide a test author by imposing a context over witch logical operations can occur. This separates what a page can do from how it accomplishes this view the Web API. It also deters a test author from trying to manipulate the page directly.
• The key feature of my Selenium WebDriver framework will be its capability to integrate other database (Excel file) to provide rigorous data driven testing. The framework will automatically generate easy to view reports along with screen shots. Coding standard should be adhered while creating libraries, business component and logging reports. My Selenium WebDriver framework will implement Page Object model which is the disengaging Application Objects from test scripts. This will eliminate code duplication and also various functions can be called multiple times.
• In Selenium Test Automation system, I will create Static method inside Page Object Class for identifying each element. These methods will return object WebElement. This way Object Repository will be constructed for the Automation system. This Selenium WebDriver framework will implement Business Process Framework which is to combine a set of actions in to a methods. While using various methods, the test automation system will ensure parameters can be passed when calling methods.
• My Automation system will feature User Defined functions and Constant Variable (Java feature) for fixed data. The Automation system will use a Logging system to provide information regarding failure, Time stamp of an issue etc.
• The notable implementation of the Selenium WebDriver test automation system is to featuring TestNG framework for XML reporting , and to run test cases in a group.
• A worthy feature of my Test Automation system would be Exception handling. Using Java feature “Try Catch” while searching object, the Automation System will display logs and screen snaps for any exception.
• A number of tools and applications are required for implementing this robust Selenium Automation framework. All are open source and free. We will use Java SE on Eclipse IDE for project building. The automation project will start by adding all Selenium jar files and other library files as external jars to the project. Need to install TestNG as an Eclipse plugin. It is recommended to add JUnit as external jar.
Further Recommendation: Selenium Framework
My automation system recommend Selenium Grid in the later stage. Also recommend Behaviour Driven Development for future project. Thinking future possibilities of BDD activities, my automation system will have the support to implement Cucumber as BDD tool. Cucumber-JVM plugin will be added to Eclipse. Consideration required if we use Maven to start up with the project. Maven would give standard directory structure and I could add many dependencies specially Cucumber libraries in Maven POM file during project startup. However dependency management is suitable for large scale development requirement.
Installation Link: Different Application Component
• Download Java SE Development Kit 8 from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
• Download Eclipse IDE for Java EE Developers from https://www.eclipse.org/downloads/
• Install Selenium WebDriver
o Go to <Selenium HQ> website and download Selenium-Java Jars.
o Go to Project properties-> Library-> Add external jars.
o Add all jars from Selenium-Java directory.
• Install TestNG
o For the Eclipse plug-in, Select Help->Install New Software
o Enter http://beust.com/eclipse in Work with box and click on ADD then name that on popup box
o Under Name, Select TestNG and follow Eclipse direction to finish installation
o Navigate to Maven Central Repository (search.maven.org) and search org.testng
o Download testng jar add to the project build path through external jar.
• Install JUnit
o Download Junit jar from http://www.junit.org. and add it through project build path through external jar
o Or you can add that from Maven pom later on
o Assume eclipse has inbuilt junit plugin and available in C:\>eclipse/plugins directory. Otherwise download plugin zip from JUnit Plugin, unzip that in the plugin folder of the eclipse and restart eclipse.
• Install Maven
o Download Maven from maven.apache.org and follow the instruction (http://maven.apache.org/download.cgi#Installation) for Maven installation
o Test Maven from command prompt mvn –version
• Environment Variable for Java and Maven
o Find required environment variable from http://maven.apache.org/download.cgi#Installation
o I added Environment Variable for Java and Maven in both User variables and System Variables. Make sure appropriate Strings for Java and Maven are added to the Path environment variable of System Variables.
• Install Cucumber JVM Eclipse Plugin 0.2.3 from help-> Eclipse market place
• Maven project and integration with Eclipse
o Create POM file executing following command (from your desired directory)
mvn archetype:generate -DgroupId={your project packaging} -DartifactId={your project name} -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
o Add following dependency after checking current version from Maven central repository (https://search.maven.org/) :
cucumber-core 1.1.7, cucumber-java 1.1.7, cucumber-junit 1.1.7, cucumber-picocontainer 1.1.7, cucumber-html 0.2.3, gherkin 2.12.2
For example:
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.1.7</version>
<scope>test</scope>
</dependency>
o Now execute command <mvn clean package> from your artifactId /project name folder
o You may need to install m2eclipse (maven-eclipse integration). I used Kepler JEE eclipse that comes with maven integration.
o Import your maven project from Eclipse File->Import and follow the direction
Following are some good Reference:
http://c0deattack.wordpress.com/2012/04/01/cucumber-jvm-example-continued-refactoring/
http://zsoltfabok.com/blog/2011/12/cucumber-jvm-preparation/
http://aslakhellesoy.com/
http://stackoverflow.com/questions/16727986/cucumber-feature-files-are-not-executed-using-maven