cancel
Showing results for 
Search instead for 
Did you mean: 

DDT using Excel sheet

Highlighted
Occasional Contributor

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

    

}

Thanks.
Regards,
Payal
13 REPLIES 13
Highlighted
New Contributor

Hello All,





I have an issue,  I need to retrive data from an excel where there are subcolumns of the main headers,



like,



Function                                                           DTM                                       DTM1

                                                                Status            Data                 Status        Data

fnc_createnew                                        Y                  ravindra            Y                 Bhapri

fnc_sendMessage                                 Y                  asfsdg              Y                 saffaff



In the shown excel format,i will get the main coulmn data from some global variables.  if the global variable give the column name as  DTM  then it should read the values of "status" and "data" sub coulumns of DTM,



in the similar way if the if my global variable has the values of DTM1, it should read "Status" and "Data" sub columns of DTM1.



I tried using DDT method, but i could not able to read values which are present under sub coulms(status, data).



Need help on this please....
Ravindra
Highlighted
Frequent Contributor

Hi



I think that the column headers must be on the first row in the spreadsheet, not split over 2 rows. You could combine the the header on the first row as "DTM1 Status" and "DTM1 Data" even though it might look a bit ugly.



http://support.smartbear.com/viewarticle/56928/






  • The column names that will be used are defined by the FirstRowHasNames registry subkey of the driver settings key (see above):





    • When key value is False (00), the columns are named automatically by the data provider (F1 would represent the first field, F2 would represent the second field, and so forth) and the first row is considered as a data row.





    • When key value is True (01), TestComplete reads textual values stored in the cells of the first row (A1, B1, C1, and so forth) and stores these values as column names. TestComplete exits the loop when it finds an empty cell. If the first row does not have headers (or contains numeric values), the data provider automatically names the fields for you and the data of the first row is omitted.






Highlighted
New Contributor

Hello,



Can any body please tell me,



How can i open a perticular sheet in the excel workbook with its SHEET name(not by its index) using COM objects.





Ravindra
Highlighted
Community Manager


Hi Ravindra,


 


You can use the following sample:




  app = Sys.OleObject("Excel.Application");


  book = app.Workbooks.Open("<FileName>");


  sheet = book.Sheets("<SheetName>");



---------
Tanya Gorbunova
SmartBear Community Manager

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get properties of a web page element

See replies!

Compare images using the Region Checkpoint

See replies!

Compare HTML table with Excel file and correct data in Excel file

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!
Top Kudoed Authors