Wednesday 28 October 2015

What is Quick Test Professional Step Generator

The Step Generator box enables you to add steps that perform operations, using test object methods (for tests only), Utility object methods, or function calls. Go to Insert -> Step Generator or Press F7 on keyboard to enable Step Generator dialog box. 


Saturday 3 October 2015

Create selenium WebDriver project in eclipse with Apache maven

The Problem
I often see Selenium practitioners ask that I have downloaded necessary resources to work on Selenium WebDriver. But, What should be project structure, how to manage dependencies, How to do build  and test management etc.

A Solution
By leveraging Apache Maven in our test framework, we can manage entire life-cycle of a test project. It provides support to define project structure, download the project dependencies libraries automatically, build and test management etc. Maven allows us to get all the Selenium libraries files and their dependencies by configuring the pom.xml (POM – Project Object Model) file.

Let’s dig in with an example

An Example
We will use Eclipse IDE and Maven for building the Selenium WebDriver test framework.
  1. Launch the Eclipse IDE.
  2. Create a new project by selecting [File -> New -> Other] from Eclipse Main Menu.
  3. On the New dialog, select [Maven -> Maven Project] as shown in the following screenshot:

  1. Click on [Next], the New Maven Project dialog will be displayed. Select the [Create a simple project (skip archetype selection)] check-box and set everything to default and click on the Next button as shown in the following screenshot: 

  1. On the New Maven Project dialog box, enter base package name (like com.myproject.app) in Group Id and project name (like myproject) in Artifact Id textboxes. You can also add a name and description but it is optional. Set everything to default and click on the [Finish] button as shown in the following screenshot:


  1. Eclipse will create the myproject project with a structure (in Package Explorer) similar to the one shown in the following screenshot:

7.       
           7. The JRE version might change based on the Java version installed on your machine. 
              Right-click on JRE System Library [J2SE-1.5] and select the Properties option from the 
              menu.       
  1. Select pom.xml from Package Explorer. This will open the pom.xml file in the editor area with the Overview tab open. Select the pom.xml tab instead.
  2. Add the WebDriver and TestNG dependencies highlighted in the following code snippet, to pom.xml in the <project> node:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
         <modelVersion>4.0.0</modelVersion>
         <groupId>com.myproject.app</groupId>
         <artifactId>myproject</artifactId>
         <version>0.0.1-SNAPSHOT</version>
<dependencies>
     <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>2.42.2</version>
    </dependency>
   <dependency>
                  <groupId>org.testng</groupId>
                  <artifactId>testng</artifactId>
                  <version>6.8.8</version>
   <scope>test</scope>
   </dependency>
</dependencies>
  <build>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </testResource>
      <testResource>
        <directory>src/test/java</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </testResource>
    </testResources>
   
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
    </plugins>
    </build>
/project>

  1. Right click on pom.xml from Package Explorer & Select [Run As -> Maven Install]

Conclusion
If you'd like to see the code and example used in the above project, you can find them here.


Happy Testing!

Test Automation Framework using Jenkins, GitHub, Maven, Selenium Grid, and TestNG

The Problem
  
You’re looking to automation web application using Selenium WebDriver for a full end-to-end / UI automation testing, there could be many challenges -

Challenge 1 - Selenium tests take a long time to run, how to speed up test execution, How to run script across the browser

Challenge 2 - Your team is distributed across geography, how team members develop, debug & update would test scripts at a central repository.

Challenge 3 - How to make sure code is not broken & there is no build failure after last night script update?

Challenge 4 - Who will own the responsibility to run script & share execution result (success/failure) with team & stakeholder?

Challenge 5 - How to manage project dependency & make sure across the team same version of jar file is used.


A Solution

Solution 1 - By leveraging Selenium Grid, we could speed up test execution & reduce test execution time. It provides ability to run parallel execution of test cases on multiple browser and operating system. Setup a Selenium Grid hub and nodes to run a battery of Selenium tests quickly.
           
Solution 2 - By leveraging Git/GitHub (private/public code repository) we can maintain web-based code repository and source code management, where every team member can upload their test scripts. It also provides access control and collaboration features such as wikis, task management, and bug tracking and feature requests for every project.

Solution 3 & 4 – By leveraging Jenkins, once configured on a central machine, it runs Selenium tests automatically several times a day (or as scheduled), or even each time there is a code commit (It allows to schedule build with GitHub with the git-plugin to run job on each commit, success/failure report is shared with stakeholder via email upon completion of build job)

Solution 5 - By leveraging Apache Maven in our test framework, this is a software project management and comprehension tool. Based on the concept of a project object model (POM),Maven manages a project's resource, build, reporting and documentation from a central piece of information.

General workflow

Maintain two branches on GitHub – Master & Stable. All new development & changes happens in branch Master. Stable branch contains successfully executable test scripts.

  1. Push changes to a branch Master or Initiate a Script run by clicking on [Build Now] on Jenkins Project page
  2. Jenkins detects a change pushed to Master
  3. Jenkins pulls in the latest changes & begins to run Selenium tests
  4. Upon completion of test execution, Jenkins sends execution report via email to configured email ID

Let’s dig in with an example


An Example

Jenkins CI to manage test execution & nodes from single interface -



 POM.xml which manages project dependency, goal & project lifecycle -


Test Java class which has tests for AUT

Test Execution Report

Conclusion
If you'd like to see the code of above mentioned project,  please write to us.

 Happy Testing!

Cucumber vs TestNG : Which is better?

I have been a long time user of TestNG.  Few months back, I started exploring about Cucumber. It was a wish from my client to create automation framework using Cucumber. I searched on web & found many blogs on Cucumber & its implementation. I started with assumption that Cucumber will replace TestNG. After working for few months, I came to following conclusion they are as follows -



                    Cucumber
                        TestNG
  • Cucumber is a collaboration tool, which lets non-technical people write executable specifications. Those executable specifications test your app from the outside - like a black box.
  • Cucumber is not meant to be used as a unit testing tool.
  •  It allows to write automated acceptance tests, functional requirements and software documentation into one format that would be understandable by non-technical people as well as testing tools
  • You can implement your tests using the same language you use to discuss them with the business. 
  • Cucumber adds the overhead of plain English (or other native language) to executable code conversion
  • Good for acceptance testing

  • TestNG are unit testing tools. They are great for testing individual classes, but not great for executable specifications that are readable (and writeable) by non-technical people.
  • It facilitates to test individual classes.
  •  You can group tests using tags.
  •  TestNG supports a lot of complicated practices like priorities, grouping, listener etc. 
  •  Useful when you have to automate large number of test case

Thursday 1 October 2015

R code to get the column Name having null value

R Quick Solution:

Problem: What to know which columns have NULL value in dataset?

Solution:
Data set: r_data

> for(varr in names(r_data))
        {
            print(varr)
            print(sum(is.na(r_data[varr])))
        }

Output:
  [1] "SD_ID"
  [1] 0
  [1] "ZIP"
  [1] 0
  [1] "COUNTY"
  [1] 0
  [1] "LATITUDE"
  [1] 20

It means variable Latitude has 20 missing values. So you to investigate it and substitute the missing value based on your business requirement.