what is Keyword driven Framework or Business process Testing framework

 Keyword Driven Framework :

  1.  Keyword driven Framework is also called as  Business process testing framework.
  2. This framework is easy to follow by integrating excelsheet content and test scripts.
  3. In this framework test scripts are understandable, readable, reusable and maintainable.

Keyword Driven Framework Process :

step1: open an excel file --------  go to sheet 1  --------- enter test ids like shown bellow

Test id description run mode
test_userid  to validate userid field yes
test_password  to validate password field no
test_login  to validate login operation no 
test_allmailscount  to check all mails count no
test_unreadmails  to check all unread mails count no
test_deletemails  to check mail delete operation no

Step 2 : goto sheet2 ------ enter steps for each test like shown bellow :

step id step description method test object test data criteria result
test_userid Launch site launch N/A http://www.gmail.com N/A  
test_userid fill user id fill //*[@name='Email'] test@gmail.com N/A  
test_userid click next click //* [@id='next'] N/A N/A  
test_userid validate userid validate_userid N/A N/A N/A  
test_userid close site close N/A N/A N/A  

sheet2

Step3:

Go to eclipse ide --------- cfeate java project ----------- associate required jars like selenium, jxl ... etc ------ create package -------- create class without main() method ------- in this class implement methods with automation code like shown bellow

public Gmailmethods

{

WebDriver driver;

public String launch(String o, String d, String c)

{

 System.setProperty("webdriver.chrome.driver", " chromedriver.exe file path ");

driver = new ChromeDriver();

driver.get(d); // here d is test data

Thread.sleep(5000);

return("done");

}

public String fill(String o, String d, String c) throws Exception

{

  driver.findElement(By.xpath(o)).sendkeys(d);

 Thread.sleep(5000);

 return("done")

}

public String click(String o, String d, String c) throws Exception

{

 

driver.findElement(By.xpath(o)).click();

 Thread.sleep(5000);

 return("done")

}

public String validate_userid(String o, String d, String c) throws Exception

{

  if(c.equalsIgnoreCae("valid")&& driver.findElement(By.name("Passwd")).isDisplayed())

   {

    terurn ("Test passed");

   }

elseif(c.equalsIgnoreCae("invalid")&& driver.findElement(By.id("errormsg_0_email")).isDisplayed())

{

   return(" Test Passed ");

}

else

  {

return("Test failed");

   }

}

public String close(String o, String d, String c) throws Exception

{

  driver.close();

Thread.sleep(5000);

return("done");

}

}

 

Gmaildriver class:

public Gmaildriver

{

  public static void main(String[]args)

  {

// create object for methods class

Gmailmethods gm = new Gmailmethods();

Method m= gm.getMethods();

// Open excel file

File f = new file ("kwexcel.xls");

Workbook rwb = Workbook.getWorkbook(f);

// go to sheet1 for reading

sheet rsh1 = rwb.getSheet(0);

int nor = rsh1.getRows(); // number of tests

// go to sheet2 for reading and writing results

Sheet rsh2 = rwb.getSheet(1);

 int nor = rsh1.getRows(); // number of steps

WritableWorkbook wwb = Workbook.createWorkbook(f,rwb);

WritableSheet wsh2 = wwb.getSheet(1);

// First row of sheet1 have column names

for (int i=1; i<nor; i++)

{

// get 1st column and 3rd column data of sheet1

String tid = rsh1.getCell(0,i).getContents();

String mode= rsh1.getCell(2,i).getContents();

if(mode.equalsIgnoreCae("yes"))

   {

      // first row of sheet2 have columns

       for(int j =1; j<nos; j++)

         {

           // get 1st column data

              String sid = rsh2.getCell(0,j).getContents();

               if (tid.equalsIgnoreCase(sid))

               {

                     // get 3 rd 4th 5th and 6th columns of sheet2

                      String mn = rsh2.getCell(2,j).getContents();

                          String o = rsh2.getCell(3,j).getContents(); 

                          String d= rsh2.getCell(4,j).getContents();

                         String c= rsh2.getCell(5,j).getContents();

                        for(int k =0; k <m.length; k++)

                       {

                          if (m[k].getName().equals(mn))

                            {

                                 String res = (String)m[k].invoke(gm,o,d,c);

                                 Label l = new Label (6,j,res);

                                 wsh2.addCell(l);

                               break;

                             }

                       }

                 }

 

            }

     }

  }

// save excel file

wwb.write();

wwb.close()'

rwb.close();

  }

}