Forum Discussion

payaldalal's avatar
payaldalal
Occasional Contributor
15 years ago

DDT using Excel sheet

function Main()

{

  try

  {

    // Enter your code here.

  }

  catch(exception)

  {

    Log.Error("Exception", exception.description);

  }

}





 // User Registration form DDT for Registration button

 // Creates the driver (main routine)

 

function User_Registration_Form_TestDriver()

{

  var Driver;

  var  iexplore;  

 

  // Creates the driver

  // If you connect to an Excel 2007 sheet, use the following method call:

  Driver = DDT.ExcelDriver("C:\\MyFile.xlsx", "Sheet2", true);

  TestedApps.IEXPLORE.Run();  

  iexplore = Aliases.IEXPLORE;      

  Aliases.iexplore.pageMedizzleUserRegistration1.panelBgdiv.panelMaindiv.table.cell.table.cellMainstageMinHt.panelFormcontentdiv.table.cell.linkRegister.Click();

  // Iterates through records

  RecNo = 0;

  while (! Driver.EOF() )

  {

    User_Registration_Form_ProcessData();// Processes data

    Driver.Next(); // Goes to the next record

  }

 

  // Closing the driver

  DDT.CloseDriver(Driver.Name);

  iexplore.IEFrame.Close();

}







//Data Driven testing for Register button for user registration form

var RecNo;

// Posts data to the log (helper routine)

function User_Registration_Form_ProcessData()

{

 

  /**

  * Test1 is to test working of cancel button in User Registration Form

  */

  var  iexplore;

  var  page;

  var  panel;

  var  table;

  var  passwordBox;

  var  checkbox;

  var i;

  /**

  * The TestedApp object holds one item (Windows-based application) from the list. It has methods and properties that can set application attributes, launch or close the application, etc.

  */

    

  /**

   * iexplore is object of TestApps and IEXPLORE is unique name of TestApps

   */

   for(i=0 ;i<DDT.CurrentDriver.ColumnCount; i++)

   

  iexplore = Aliases.IEXPLORE;

  Aliases.iexplore.IEFrame.Maximize();

  /**

  * An alias is just another name for a name mapping item. Aliases can be organized in a tree, so, you can, for example, shorten the mapping path to Aliases.Explorer1.PageObj.

  * Aliases tree provides a simplified hierarchy, where intermediate objects (such as layout containers) can be skipped in order to reduce the syntax used to refer to the mapped object in tests and this way improve the test readability

  */

  // clicks on Registration link

 

  page = iexplore.pageMedizzleUserRegistration;

  page.Wait();

  panel = page.panelBgdiv.panelMaindiv.table.cell.table.cellMainstageMinHt.formRegisterForm.panelContentdiv;

  table = panel.panelUserselectiondiv.table;

  table = panel.panelFormcontentdiv.table.cellFormfieldpadding.panelFormfielddiv.table;



  //Enter First Name

  table.cell.textboxTxtfirstname.Text = DDT.CurrentDriver.Value("First Name");



   //Enter Last Name

  table.cell10.textboxtxtlastname.Text = DDT.CurrentDriver.Value("Last Name");



    //Enter Email Address

  table.cell7.textboxTxtemailid.Text = DDT.CurrentDriver.Value("Email address");



  //Enter User Name

  table.cell1.textboxTxtusername.Text = DDT.CurrentDriver.Value("User Name");



    //Enter password

  passwordBox = table.cell2.passwordboxTxtpasswd.Text=DDT.CurrentDriver.Value("Password");



  //Enter password again

  passwordBox = table.cell8.passwordboxTxtconfirmpasswd.Text=DDT.CurrentDriver.Value("Confirm Password");



   //Select Gender

  if(DDT.CurrentDriver.Value("Gender")=="Male")

  {

 

  table.cell3.table.cell.radiobuttonRadiogroup20.Click();

 

  }

  else

  {

  table.cell3.table.cell1.radiobuttonRadiogroup21.Click();

 

  }

 

  //Select Register as

  if(DDT.CurrentDriver.Value("Register as")=="Patient")

  {  

  table.cell9.table.cell1.radiobuttonRadiogroup10.Click();

      

  }

  else

  {  

  table.cell9.table.cell.radiobuttonRadiogroup11.Click();

 

  }

 

   //Enter Capcha Code

  table.cell4.textboxTxtcaptcha.Text=DDT.CurrentDriver.Value("Capcha Code");

 

  //Select Stay Connected

  if(DDT.CurrentDriver.Value("Stay Connected")=="Yes")

  {

  checkbox = table.cell5.table.cell.checkboxChknewletters.Click();

  }

  else

  {

  }

 

    //Select Privacy Policy

  if(DDT.CurrentDriver.Value("Privacy Policy")=="Yes")

  {

  table.cell6.table.cell.checkboxChkprivacy.Click();

  }

  else

  {

    Log.Message("Select the Privacy Policy");

  }

    if(i<=DDT.CurrentDriver.ColumnCount)

    {

    table.cellRegistrationfieldtxt.table.cell1.panelButtonBlueDisplay.submitbuttonSubmit.Click();

    }

    

    else

    {

    table.cellRegistrationfieldtxt.table.cell.panel.resetbuttonInput.Click();

    }

  //iexplore.IEFrame.Close();

  //aqUtils.Delay(2000);

    

}