Selenium TestNG TestDriven


from OpenQA : All Content - Se: Advanced Techniques and Automation by

Well, some basic Java (relativelly speaking) would help a lot. At work we  use Selenium, TestNG and Ant (we use Eclipse only to write tests, not to run them).


Our set up is very similar to this:   In fact this is scaled down version what I use at work.


There is one more folder called data (and guess what it holds excel files).   We modify our Selenium tests to read from excel files (  we use this one, there is also You can create your own helper class that fits your needs. 


Excel files can be organized in any way you want.




advantage of doing it this way:


      public void testNew() throws Exception {
           selenium.type("q", "selenium rc");
           assertTrue(selenium.isTextPresent("Results * for selenium rc"));
           // These are the real test steps

if you look at selenium.type("q", "selenium rc");
your excel file can hold   values, and pseudo code would be something like :

// you will need to specify exact cell in your spreadsheet
   searchString = sheet.getCell(0,row).getContents(); 
   clickOnThis = sheet.getCell(1,row).getContents();
   waitingPeriod =   sheet.getCell(2,row).getContents();
   expectedResult = sheet.getCell(3,row).getContents();
     selenium.type("q", searchString); );
    selenium.waitForPageToLoad(waitingPeriod );

if you want to change search string, you just edit spread sheet and enter different string. if Google changes the name for the button,
same story: just edit excel file, etc.  there is no need to change you Java code, plus code is much easier to understand

this way, you write your test once and usualy there is no need to change Java code often.
most of the time you edit your excel files 

when I have time (no promises here) I will try to add excel helper class  to the example posted at