We know Selenium IDE is one which is used by many manual testers and does not require knowledge of any programming language. But a manual tester can become an automation engineer using fitnesse. The developer need to create a framework using selenium rc/webdriver with any programming language like java, C# etc and integrate with fitnesse. There is no need to have knowledge of junit and testing framework.
I will show how this can be done step by steps
- Download fitnesse from http://fitnesse.org/FrontPage.FitNesseDevelopment.DownLoad
Unzip downloaded folder to any drive like C:\fitnesse
- Download selenium from http://seleniumhq.org/download/
Keep selenium-server-standalone-2.21.0.jar in C:\fitnesse
- Start fitnesse server clicking run.bat or from command prompt type java -jar fitnesse.jar
- Now open your browser and go to http://localhost. You will see the FitNesse home page.
- Click on Edit menu at left pane. Remove introduction note from home page and create project. We need to set path as shown below once our project is created.
!path selenium-server-standalone-2.21.0.jar
!path fitnesse.jar
!path lib/fitlibrary.jar
!path D:\Workplace\Fitenium\bin
Also configure SetUp and TearDown as if required.
- Make sure that you have created project Fitenium using eclipse in D drive in Workspace. Below I have created sample java class which utilizes java fixture wrappers around selenium call.
package com.sample.automation.framework;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.sample.automation.browser.Browser;
import fitlibrary.SequenceFixture;
/*
* This class extends SequenceFixture so that we can create and use java style fixture in fitnesse*/
public class FitSeleniumFramework extends SequenceFixture
{
private static WebDriver driver;
public void initializeBrowser() {
driver = new FirefoxDriver();
}
public WebDriver getWebDriver() {
return driver;
}
public void stopBrowser() {
if(driver != null) {
driver.quit();
}
}
/*
* This is a fixture which we use to open home page url
*/
public void navigateToHomePage(String url) {
initializeBrowser();
try {
getWebDriver().navigate().to(url);
}catch (Exception e) {
System.out.println(“ERROR OPENING THE ” + url);
e.printStackTrace();
stopBrowser();
}
}
/*
* This fixture is used to check if particular element present on web page
*/
public boolean isElementPresent(String element) {
WebElement webElement = getWebDriver().findElement(By.xpath(element));
if(webElement != null)
return true;
else
return false;
}
- We have now two fixtures from above code
navigateToHomePage(String url)
isElementPresent(String element)
- Edit Project and create test suite namely HomePageSuite. Use Properties menu from left pane to change properties of page.
- Edit suite created in fitnesse and create test case namely “HomePageElements”. Write fixture in test case like
|navigateToHomePage|http://kayak.com|
|check|isElementPresent|//input[@id=”origin”]|true|
|check|isElementPresent|//input[@id=”destination”]|true|
|check|isElementPresent|//button[@id=”fdimgbutton”]|true|
- Run test case clicking Test button from left pane.
Once tester got familiar with fixture, effectively he can start productively automating test cases without any programming experience. There is no need for the whole team to know java and selenium or any other programming language. By just understanding wiki markup and xpath or css, non-technical person can write test cases using fitnesse.