FitNesse and Selenium

When we create our Selenium tests in Java normally we use JUnit or TestNG frameworks to execute our test scripts. We can also use FitNesse tool as a framework for our Selenium tests. FitNesse can be used when we have the below scenarios:

  • When we need to pass number of parameters to the script
  • When we need to run the same script with different parameters
  • When we need to run the same script with different URLs as parameters (functionality will be same).

You might have this question running in your mind!! Can’t we use JUnit or TestNG to achieve the above things. Answer to this question will be, YES, we can use. But, we need to go for the concepts like Data Providers and JXL (Read data from Excel sheet) while using JUnit or TestNG.

When we use FitNesse, we can simply achieve the above things without Data Provider and JXL. Also, we doesn’t require any technical person to execute our scripts. Once the test scripts are configured with FitNesse, any one can execute the scripts from there.

Just to give a try, follow these steps:

  1. Download FitNesse from here.
  2. Once its downloaded, create a folder called FitNesse in C or D drive and move the downloaded file(fitnesse.jar) into this folder.
  3. Go to command prompt and open this folder C:\FitNesse
  4. Type java -jar fitnesse.jar and press enter. FitNesse jar file will be unpacked and you will find a additional folder called FitNesseRoot which will be having all the supporting files
  5. Again type java -jar fitnesse.jar and press enter. This time your FitNesse server will be started. If it ask you to choose the different port, use -p argument with the above command: java -jar fitnesse.jar -p 8081
  6. Now open your browser and go to http://localhost. You will see the FitNesse environment.
  7. You will see some introduction notes on the home page. Click on Edit from left navigation and remove all the notes and configure your Java test scripts and jar files. You need to include the below things:
    • !contents
    • !path C:\Fitnesse\FitNesseRoot\files\classes
    • !path C:\Fitnesse\lib\*.jar
  8. Make sure you have created the folder called “classes” under C:\Fitnesse\FitNesseRoot\files location and included all your test scripts (Java class files). Also make sure you have created lib folder under C:\FitNesse and included all the necessary jar files: FitNesse.jar, selenium-java-client-driver-2.x.jar, selenium-server-standalone.jar
  9. Once you have configured your test scripts and jar files, click on save to update the changes. Now you can only see your test script and jar file configuration paths on your FitNesse home page. Whenever you open FitNesse, you will see this path.
  10. Now click on Add Child on the top of the home page to create a Test Suite and Test and enter a name. Make sure you have minimum two words in the name and each word should start with capital letter. For Example, TestSuite – SampleSuite and Test – SearchCheck.
  11. Now you can see your suite on the home page. Click on that, you will find your Test. When you open that, you will get Edit option in the left navigation. Click on that and call your test script. Follow the below format:
    • !|package name.class name|
    • |parameter name|method name|
    • |parameter value|Expected Outcome|
  12. For Example, if you have created a class SampleClass under the package Sample in Java. Assume that you have a test method “firstMethod()” and a parameter “searchString”
    • !|Sample.SampleClass|
    • |searchString|firstMethod()?|
    • |Sachin|True|
  13. Remember that we are passing the value for the variable searchString from FitNesse, but the variable should be declared in your java code.
  14. If you want to pass number of parameters, you need to include as follows:
    • !|Sample.SampleClass|
    • |searchString|firstMethod()?|
    • |Sachin|True|
    • |Yuvraj|True|
    • |Dravid|True|
    • |Dhoni|True|
  15. After adding all your parameters, save the changes and click on Test on the left navigation. But, make sure you test script is created and the class file has been stored in this location: C:\Fitnesse\FitNesseRoot\files\classes
  16. I have created a test script with Same class and test method. You can try this example:
package Sample;
import com.thoughtworks.selenium.DefaultSelenium;
import fit.ColumnFixture;
public class SampleClass extends ColumnFixture {
public DefaultSelenium selenium;
public String searchString;
public SampleClass()
selenium = new  DefaultSelenium(“localhost”, 4444, “*firefox”, “”);
public boolean firstMethod() throws Exception
selenium.type(“name=q”, searchString);“btnG”);
return selenium.isTextPresent(“News for “+searchString);

Finding broken images in a webpage using Selenium

We were checking for broken URLs using Selenium in the previous post. Now we are going to see how to find broken images in a webpage. Broken images are also called Red-X images. We have some tools in the market for finding red-x images on a website or webpage. For example, InSite which is a windows based application.

The same functionality can be possible with Selenium script. How do we do that?

  • We need to find the number of images on the page
  • We need to track the properties of each and every image.
  • Finally we need to extract the image size amd check if its broken or not
How to find the number of images on the page?
We can find the number using selenium.getXpathCount(“//img”).intValue() method.


selenium=new DefaultSelenium(“localhost”, 4444, “*firefox”, “”);
int linkCount = selenium.getXpathCount(“//img”).intValue();
How to track the properties for each and every image?
We can use the for loop and track the properties of the image one by one.


  for (int i = 1; i < imageCount; i++)
String currentImage = “this.browserbot.getUserWindow().document.images[” + i + “]”;



How to extract the image size from the image property?

String s = selenium.getEval(“(!” + currentImage + “.complete) ? false : !(typeof ” + currentImage + “.naturalWidth != \”undefined\” && ” + currentImage + “.naturalWidth == 0);”);
System.out.println(selenium.getEval(currentImage + “.src”));

Find the complete script below:

import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestBase;

public class FindBrokenImages extends SeleneseTestBase{

DefaultSelenium selenium;
public int invaildImg;

public void SetUp()
selenium = new DefaultSelenium(“localhost”, 4444, “*firefox”, “”);

public void testMethod() throws IOException {

catch (Exception e)
int imageCount = selenium.getXpathCount(“//img”).intValue();
FileOutputStream fout = new FileOutputStream (“broken_images.txt”, true);
new PrintStream(fout).println(“URL : ” + selenium.getLocation());
new PrintStream(fout).println(“——————————————–“);
for (int i = 1; i < imageCount; i++) {
String currentImage = “this.browserbot.getUserWindow().document.images[” + i + “]”;
String s = selenium.getEval(“(!” + currentImage + “.complete) ? false : !(typeof ” + currentImage + “.naturalWidth != \”undefined\” && ” + currentImage + “.naturalWidth == 0);”);
// System.out.println(selenium.getEval(currentImage + “.src”));
new PrintStream(fout).println(selenium.getEval(currentImage + “.src”));
invaildImg++; }
new PrintStream(fout).println(“Total broken images = ” + invaildImg);
new PrintStream(fout).println(” “);


public void tearDown()

The above script will identify all the broken images(if any) in and store the image URLs in a notepad file called broken_images.txt. If you want to check the broken images for N number of URLs, you can pass the parameters through Data Provider concept or Excel sheet using JXL package.

How can I have better career growth in Software Testing?


The profession of software test is undergoing heavy changes at the moment: Agile teams erase the border between developers and testers, technology changes with growing speed and system get more complex with each release.

A demanding environment with customers calling for shorter time to market. Some might say that test is dead but if you look at it the tester is the protector of the brand (according to Theresa Lanowitz) so it is a profession with a future.

Your career is always limited by the company or industry you are in. Some positions might only allow specialization. You will need to specialize after you have a wide area of knowledge. Don’t forget your social skills. Development and test will move closer to the business units and you will need to communicate and team work a lot. Don’t look at testing as a technical thing. Also see it from the business view.

Last something on test automation (which is only a part of the puzzle):

If you stay a manual tester, you won’t stay a tester like you are today. If you go through the sources out there and look at where testing is going you will find one thing:

Test automation rates will rise. Not just because of the so called shift left (continuous delivery, agile, devops,….) but also because we start to see the shift in the technology created.

Skills required to become a Software Tester


Following skills are indispensable to become a good software tester. Compare your skill set against the following checklist to determine whether Software Testing is a really for you-

  • A good software tester should have sharp analytical skills. Analytical skills will help break up a complex software system into smaller units to gain a better understanding and created corresponding test cases. Not sure that you have good analytical skills – Refer this link –  if, if you can solve atleast ONE problem you have good analytical skills.
  • A good software tester must have strong technical skills . This would include high level of proficiency in tools like MS Office , OpenOffice etc , Testing tools like QTP , Loadrunner , etc.. and ofcourse deep understand of the application under test. These skills can be acquired through relevant training and practice. Also it’s an added advantage that you have some programming skills but its NOT a must.
  • A good software tester must have a good verbal and written communication skill. Testing artifacts (like test cases/plans, test strategies, bug reports etc) created by the software tester should be easy to read and comprehend. Dealing with developers (in case of bugs or any other issue) will require a shade of discreetness and diplomacy.
  • Testing at times could be a demanding job especially during the release of code. A software tester must efficiently manage workload, have high productivity ,exhibit optimal time management and organization skills
  • To be a good software tester you must have a GREAT attitude. An attitude to ‘test to break’ , detail orientation , willingness to learn and suggest process improvements. In software industry, technologies evolved with an overwhelming speed and a good software tester should upgrade his/her technical skills with the changing technologies. Your attitude must reflect a certain degree of independence where you take ownership of the task allocated and complete it without much direct supervision.
  • To excel in any profession or job, one must have a great degree of the passion for it. A software tester must have passion for his / her field. BUT how do you determine whether you have a passion for software testing if you have never tested before? Simple TRY it out and if software testing does not excite you switch to something else that holds your interest.

Choosing Software Testing as your Career


I will give a common answer to all these questions whether you should choose software testing as your career or not? Let me first explain in brief about software testing. Software testing and quality control are the processes by means of which application quality is improved. Software testing is done in each phase of product life cycle i.e from requirement specifications , design, coding, to the user acceptance.

Many complex software structures require in depth analytical and technical skill to test the applications. Knowledge of programming languages is required for unit testing, scripting skill essential for Automation testing.

Now we will speak about your career in software testing. No one can guide you choosing your career more than you! Its right and you are the only person to decide your career.
Do self-assessment to figure out where you can fit well. Do study of your skills, interests, strengths, weaknesses.

Ask some questions to your self like:
What is your goal in life?
What will increase your satisfaction and skill?
What is your interest?
Which skills you have developed in your life till now?
Which training you did that can be applied to future job?

By answering these questions you will automatically come to decision.

To switch to software testing career What skills you will require? Is the most important question I think.

In my previous post what makes a good test engineer, I mentioned some of the software testing required skills.

1. Communication: Customer communication as well as team communication most important for this job. Written communication as well!

2. Technical skill: As I mentioned earlier for testing technical domain skill in languages is important.

Some of the Testing skills are:
Project life cycle,
Testing concepts,
Knowledge of testing types,
Programming languages familiarity,
Database concepts,
Test plan idea,
Ability to analyze requirements,
Documentation skill,
Testing tools