Sunday, 10 March 2013

Test Case(s) Conversion

Navigate to the RegressionTestHarness directory
Make a directory named convert at the root level. This is a ONE time only process
Place the generated file(s) in to the convert directory


From the RegressionTestHarness root directory and run ant convert
Specify the browsers that you wish to test against for the file(s) in the convert directory







































From the RegressionTestHarness root directory and run ant compile and correct any compilation errors.



















 




Saturday, 9 March 2013

Installation

Download the source code ZIP file for the project from here

From the downloaded zip file named Selenium-Regression-Project-master.zip  you need to extract/copy the folder named RegressionTestHarness to a desirable location.

You should also import the RegressionTestHarness project folder into eclipse using: 

File -> Import -> General -> Exising Projects into Workspace

Finally download and install ANT if not already installed.
Also ensure you have the Chrome, Firefox and Internet Explorer (if applicable) browsers installed.

The Project Structure




























 

Record & Export Test Case(s)

Using Selenium IDE lets start recording our first test case
Navigate to your website and open up Selenium IDE 
lets use http://www.google.com for our example


Now minimise Selenium IDE window/popup that has opened.

Lets do a google search for "WebDriver API" and click on the search button
  

Restore the Selenium IDE window/popup  




Now export the test case and save as a suitable name.
I exported it as Java / JUnit 4 / WebDriver


Close Selenium IDE window/popup ignoring the following message


You should have a java file generated that contains the following code 
Please note I saved my exported test case as test1

package com.example.tests;

import com.thoughtworks.selenium.*;
import org.testng.annotations.*;
import static org.testng.Assert.*;
import java.util.regex.Pattern;

public class test1 extends SeleneseTestNgHelper {
 @Test public void testTest1() throws Exception {
  selenium.open("/");
  selenium.type("id=gbqfq", "WebDriver API");
  selenium.click("id=gbqfb");
 }
}





Welcome

Welcome to the my blog. In this blog I will share my knowledge about Selenium.

What is Selenium?

Selenium WebDriver is an open source browser automation (test) tool suite. Which enables you to run your tests against many browsers and operating systems. Another advantage is that you can write your tests in the programming language you prefer, in my case Java.

The Problem

I am currently working on a project delivering a web based application. The current regression pack that gets executed against the application consists of several manual test scripts that take a long time to execute.

The Solution

I  recommended that we use Selenium 2.0  to automate the process. Given my previous experience in using Selenium 1.0 I was tasked to produce a hareness which was easy to configure (test application on numerous browsers) and could be used by both the development and test teams.

The approach taken was to record scripts using the SeleniumIDE and export these as JUnit or TestNG tests to build up an automated regression pack. 

The scripts were executed using Selenium 2.0 with screen shots being captured to enable visual comparison.These scripts have now become our regression pack of automated tests that we use to test against multiple environments and multiple browsers in a fraction of the time previously taken by manual scripts.

You can read more about Webdriver and Selenium2.0 here