Road to create java maven project.

In this post I explain the procedure to create java maven project.  Before creating maven project you must have following setup in your system.
  1. Java 
  2. Maven
  3. Eclipse
Create Maven project:  create a folder in your system as I created “MavenProject” folder in D drive. Open command prompt, go to created project and run below command.

mvn archetype:generate -DgroupId={ProjectPackage} -DartifactId={ProjectName} -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Road to execute java webdriver testNg suite using ant build.

In this post, I will explain how to execute webdriver java test script using ant build tool.for this first we need to setup following in our machine.
  1. Java should be installed on machine.
  2. Selenium2 jar file.
  3. TestNG jar file.
  4. Ant should be installing and setup path in system environment variable.
Webdriver Test scripts.
I have created two webdriver test scripts in java on Wikipedia web application as mentioned below.
NavigateURL.java

package com.webdriver.test;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

public class NavigateURL {
                   
                    private WebDriver driver;
                    private String baseUrl;
                     
                    @BeforeSuite
                    public void setUp() throws Exception {
                       driver = new FirefoxDriver();
                       baseUrl = "http://www.wikipedia.org/";
                       driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
                     }

                     @Test
                     public void testUntitled() throws Exception {
                       driver.get(baseUrl + "/");
                       driver.findElement(By.xpath("//a[contains(@title, \"English — Wikipedia\")]")).click();
                       driver.findElement(By.linkText("Contents")).click();
                       driver.findElement(By.cssSelector("a[title=\"Featured content – the best of Wikipedia\"]")).click();
                       driver.findElement(By.cssSelector("a[title=\"Find background information on current events\"]")).click();
                       driver.findElement(By.linkText("Random article")).click();
                     }

                     @AfterSuite
                     public void tearDown() throws Exception {
                       driver.quit();               
                     }
}
SearchCountry.java


package com.webdriver.test;

import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

public class SearchCountry {
                   
                    private WebDriver driver;
                     private String baseUrl;
                     
                      @BeforeSuite
                      public void setUp() throws Exception {
                        driver = new FirefoxDriver();
                        baseUrl = "http://www.wikipedia.org/";
                        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
                      }

                      @Test
                      public void testUntitled() throws Exception {
                        driver.get(baseUrl + "/");
                        driver.findElement(By.xpath("//a[contains(@title, \"English — Wikipedia\")]")).click();
                        driver.findElement(By.id("searchInput")).clear();
                        driver.findElement(By.id("searchInput")).sendKeys("India");
                        driver.findElement(By.id("searchButton")).click();
                        String searchedResult = driver.findElement(By.xpath("//h1[@id='firstHeading']/span"))
                                                             .getText();
                        Assert.assertTrue(searchedResult.equals("India"));
                      }

                      @AfterSuite
                      public void tearDown() throws Exception {
                        driver.quit();              
                      }
}


Now we create testNg suite file as in my case, below is testng suite file created for the above test scripts


Road to handle http authentication in webdriver

One of my applications had Http authentication for security purpose and I had need to automate using webdriver. As we know http authentication is not a part of DOM object so we cannot handle it using webdriver. Here is approach to handle such type situation.

We need to pass http credential with URL to skip http popup authentication window. Below is URL format.


User above formatted URL in webdriver get method:


After using above approach, http authentication popup window disappear. But in Internet explorer, it raise error with message “wrong format url”. To accept same type url in internet explorer browser we need to add a DWORD value named exploere.exe and iexplore.exe  with value data 0 in below registry.
To open registry, open "regeidt" from run command.

  1. For all users of the program, set the value in the following registry key: HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE
  2. For the current user of the program only, set the value in the following registry key: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE 
  3. If you are using 64 bit machine, set the value in the following registry key. HKEY_CURRENT_USER\Software\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE

Road to automation using watir for beginner

Watir installation:
1. Download and install the latest Ruby version from link “Ruby”. Setup ruby bin folder path to system environment variables. After installation and setup path run command:
ruby -v

2. setup OK if you get ruby version as a message.
gem  -v

3. You should update gem by using command.
gem  update --system

4. Watir and watir-webdriver gems need to “ffi” gem, and it needs Ruby Installer Development Kit (DevKit). Download DevKit  from link DevKit. and follow installation process as mentioned in url http://github.com/oneclick/rubyinstaller/wiki/Development-Kit 
5. After DevKit successful installation, you need to install water and watir-webdriver by running following commands.
gem install watir
gem install watir-webdriver

6. After successfully installation of watir and watir-webdriver run some below commands to verify installation.
>irb

            Below message should be displayed
            DL is deprecated, please use Fiddle
            irb(main):001:0>
>require "watir-webdriver"
            Message “true” should be displayed           
>browser = Watir::Browser.new :ff
               Firefox browser should be open

Road to jmeter test execution with maven

In this post I explain the procedure of Jmeter test execution using maven build tool. 

Setup:

1. Download and setup java path in your system environment path.
2. Download and install Jmeter.
3. Download and setup maven bin path in your system environment path

Road to correlation in Jmeter test script

Today, I continue posting regarding jmeter, in my previous two post I explained how to create jmeter test script and how parameterize test scripts from external file? In this post I am going to explain about correlation in jmeter

What is Correlation: correlation play most important role in jmeter scripting. It is a procedure by which fetching dynamic data from a request’s response and passing it into next request.

Why need Correlation: 
Suppose we have a login scenario in which.
     1. User enter credential and click on submit button.
     2. At dashboard click any tab.
Now, if I recoded above scenario and replay back using jmeter then test will fail. The reason behind it that authentication mechanisms use here. As when I recorded test script server automatically generated a dynamic session id which passed in next request of test for validating authentication of user. So when I executed test scripts every time a new session Id generated dynamically as user login request sent, we need to pass same session Id in next request. So these types of scenarios we need to handle using correlation of jmeter

Road to parameterization in Jmeter test script

Parameterization is process by which user input some values to test script at execution time using external files such as csv, xls, txt, xml etc. In Jmeter test, suppose we need to check login functionality with 100 set of user so in this case we parameterize users from external file. At execution time user picked dynamically .

Steps Jmeter parameterization.

1. After capturing request and responses of your web application you need to create a csv file and put data in file separated with comma. As I created below  csv file for urls parameterization


Road to Jmeter - procedure to create first test script for the beginners

Set up and installation:

1. Download java(JDK) from link "“http://www.oracle.com/technetwork/java/archive-139210.html” and setup path in your system environment variable.
2. Download apache Jmeter from link “http://jmeter.apache.org/download_jmeter.cgi”.
3. Unzip downloaded Jmeter package in your machine, go to extracted folder and open bin folder.
4. Click on “jmeter.bat” file you should see that a cmd screen and Jmeter console should opened as below.


After completing above steps you are ready to create First Jmeter script.    

Road to create test script using Pywinauto

Pywinauto is python based GUI automation tool, using this we can automate windows application.

Set up:

To set up pywinauto you need to install some prerequisite in you machine as mentioned below.
 1. Python
 2. SendKeys (SendKeys-0.3.win32-py2.6.exe)
 3. setuptools-0.6c11.win32-py2.6.exe.

Download pywinauto from link http://sourceforge.net/projects/pywinauto/files/ and unzip in your machine.
Open command prompt and go to unzip folder “pywinauto” and run command

 python setup.py install

To check you have it installed correctly