Forum Discussion

payaldalal's avatar
payaldalal
Occasional Contributor
15 years ago

DDT using Excel sheet

As i m a new user for test complete. I didnt get it how to do this..................

I m working with Jscript...........

Consider i m testing for registration form. First i fill only First name of mine clicks on Register button.Then i vl Fill First name n last name n click register button..........I vl do this untill my last field is entered after last entry i want to click on cancel button. What to do for that?

All the entries are passed by excel sheel. All test is running except that cancel button



Here is my code........................

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()

{

 

 

  var  iexplore;

  var  page;

  var  panel;

  var  table;

  var  passwordBox;

  var  checkbox;

  var i;

 

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

   

  iexplore = Aliases.IEXPLORE;

  Aliases.iexplore.IEFrame.Maximize();

 

 

  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);

    

}

13 Replies