Thursday, January 26, 2012

Getting Started with Webdriver (Java + Eclipse)


WebDriver is a tool for writing automated tests of websites. It aims to mimic the behaviour of a real user, and as such interacts with the HTML of the application. More info here.

Eclipse installation

  1. Download Eclipse (I use Eclipse Classic - don't really know what is the difference between all of them)
  2. Extract the archive to a folder (e.g. c:\eclipse)
  3. Run Eclipse.exe (I would recommend to create a shortcut and put it to the desktop or taskbar)
  4. Create a new Java Project - File/Add/Java Project. Name the project (e.g. webdriver) and accept the rest of the defaults

Webdriver setup

  1. Download the latest selenium-java-<newest version>.zip here
  2. Unzip the files into the project that you just created. I would suggest to create a folder under the project root called /lib (my example: c:\workspace\webdriver\lib\)
  3. Back in Eclipse, right click on your project in the Package Explorer and choose Properties -> Java Build Path
  4. Choose the Libraries tab and click Add External Jars...
  5. Select all the jars that you just unzipped into the /lib/ folder and click OK

Create a new test with Webdriver

  1. Add a new Package - File/New/Package (name it e.g. test)
  2. Select a new package and add a new class - File/New/Class. Give the class name (e.g. Test) and accept the other defaults, but make sure that public static void main(String[] args) checkbox is enabled. 
  3. Copy the following code into your Eclipse project and Run the test!


package test;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Test {

    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com");
        WebElement element = driver.findElement(By.name("q"));
        element.sendKeys("webdriver how to find elements");
        element.submit();
        System.out.println("Test passed!");
    }

}


As the result Google page should be opened in new FireFox window. The code in Eclipse should look like this:

Friday, August 19, 2011

Cross-site scripting (XSS) and SQL injection testing tools

If you need to test a web application for XSS vulnerability and SQL injection there are few tools you can use. Very good in combination with Fiddler. Both are easy-to-install Firefox addons.
NOTE: don't support FF4 - work OK with FF3.6

Thursday, August 5, 2010

Using multiple profiles in Firefox

I have noticed that using multiple profiles in Firefox (with different sessions, cookies, cache and preferences) is extremely useful feature. If someone doesn’t know how to use it - here is the simple steps:
1. Right-click on Firefox shortcut (from Quick Lunch or Desktop) and select Properties
2. Enter the following string to the Target field “-p –no-remote” as shown below

3. Save changes and click on the Firefox shortcut – User Profile dialog will be displayed before Firefox is started

4. Create few profiles for your needs with different preferences – so you can use different profiles separately without sharing the sessions
Enjoy!

Wednesday, June 10, 2009

The simplest testing principle

Before starting testing web-application make sure that network cable is connected.

Wednesday, June 3, 2009

The good tester

To the optimist, the glass is half full. To the pessimist, the glass is half empty. To the good tester, the glass is twice as big as it needs to be.

by eXtreme Software Testing site

Wednesday, May 27, 2009

FireShot: web pages capturing tool for IE & Firefox

FireShot is a screen shot tool that can capture just the webpage you are looking at. It can capture the visible area or the entire page. The free version is useful for basic capture/save. You can find FireShot here.

Wednesday, May 20, 2009

Firebug: well known web debugger tool

Firebug integrates with Firefox to put a wealth of web development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page. You can get it here