Forum Discussion

joffre's avatar
joffre
Regular Contributor
14 years ago

Data-Driven Testing on TestComplete 7.52

Hi everybody.



I just saw Lesson 5 of TestComplete's tutorial, and it talks about DDT. As the thread title says, my TCs version is 7.52, and I didn't find where do I have to click to "Make Data Loop", as showed on Lesson 5.



How do I use DDT on TC 7.52?



I have already seen Support Article about DDT (http://smartbear.com/support/viewarticle.aspx?aid=11918) but didn't help with my problem.



Take a look at attachments to compare my project screenshoot with Lesson's 5 screenshoot.



Thanks.



9 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    The feature you're looking at in that lesson is a feature of TestComplete 8.  See the first item in http://smartbear.com/support/viewarticle/18757/#KDT



    To do data driven loops in keyword tests in TC 7, you'll have to utilize the DDT driver objects, DDT.CurrentDriver, and other such things within your keyword test.  Take a look at the screen shots I put in to my response in this thread as an example. http://smartbear.com/forums/forum/post/?mode=singleThread&thread=3fb8b851-b8f4-43a9-9227-a94e3407cdeb


  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    One thing I would recommend for TC 7.52 is that it is probably easier to construct your DDT Loop in Script code and then call your Keyword test from within that script code.  Take a look at http://smartbear.com/support/viewarticle/13853/ for more about how to do DDT in script.



    You can then use DDT.CurrentDriver within your keyword test to indicate to use values from within whatever the most recent DDT driver.  That way you won't have to worry about creating and manipulating DDT drivers within keyword tests (not an impossibility, just I find it more difficult).
  • joffre's avatar
    joffre
    Regular Contributor
    One thing I would recommend for TC 7.52 is that it is probably easier to construct your DDT Loop in Script code and then call your Keyword test from within that script code.  Take a look at http://smartbear.com/support/viewarticle/13853/ for more about how to do DDT in script.



    You can then use DDT.CurrentDriver within your keyword test to indicate to use values from within whatever the most recent DDT driver.  That way you won't have to worry about creating and manipulating DDT drivers within keyword tests (not an impossibility, just I find it more difficult).    




    Hi Robert, how are you doing?



    I'm using scripts to fully test my application. My intention is to get data from several columns on an excel sheet and populate my form with this data.



    Doubt 1 - Where do I find this DDT.CurrentDriver? In my case, DDT.ExcelDriver (I guess).



    Doubt 2 - The example of how to use DDT.ExcelDriver isn't very clear. It shows how to import the sheet, but how will I set values from Column 1 to one TextBox?

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Doubt 1 - Where do I find this DDT.CurrentDriver? In my case, DDT.ExcelDriver (I guess).




    DDT.CurrentDriver returns the last DDT driver that was created.  So, if you do this:



    var Driver1 = DDT.CSVDriver("C:\\Temp\\Test.CSV")

    var Driver2 = DDT.ExcelDriver("C:\\Temp\\Test.XLS", "Sheet1", true)

    var Driver3 = DDT.CurrentDriver()





    Driver3  then returns the ExcelDriver because it was the last driver created.   See http://smartbear.com/support/viewarticle/13851/



    Doubt 2 - The example of how to use DDT.ExcelDriver isn't very clear. It shows how to import the sheet, but how will I set values from Column 1 to one TextBox?




    function CurDriverExample()

    {

      // Creates a driver 

      DDT.ExcelDriver("C:\\MyFile.xls", "Sheet1");

       

      // Iterates through records 

      while (! DDT.CurrentDriver.EOF)

        //... 

        Aliases.MyApp.MyForm.MyTextBox.Text = DDT.CurrentDriver.Value("MyTextData")

        DDT.CurrentDriver.Next();

       

      // Closes the driver 

      DDT.CloseDriver(DDT.CurrentDriver.Name);

    }




    Essentially, each column in the DDT driver is referenced by the Value property which you can then utilize in any way you may need to, either to populate data on a form, to use to check values on a form, to evaluate into a function to be executed, etc.  There's a tutorial on doing so in scripts found at 



    http://smartbear.com/support/viewarticle/11891/
  • joffre's avatar
    joffre
    Regular Contributor
    Sub CurDriverExample  

      ' Creates a driver 

      Call DDT.ExcelDriver("C:\MyFile.xls", "Sheet1")

       

      ' Iterates through records 

      While Not DDT.CurrentDriver.EOF

        '... 

        DDT.CurrentDriver.Next()

      WEnd 

       

      ' Closes the driver 

      DDT.CloseDriver(DDT.CurrentDriver.Name)

      

     End Sub




    On my case, I'm using VBScript. I guess the loop will be the same thing:

    Aliases.MyApp.MyForm.MyTextBox.Text = DDT.CurrentDriver.Value("MyTextData")




    I dind't understand before that DDT is a class.



    Now, one more doubt. As in the picture attached, what are the parameters that I have to pass to DDT.ExcelDriver!? It requires the path of my ExcelFile, requires a Sheet and 'UseACEDriver'. What is this sheet? And what is ACEDriver?

  • joffre's avatar
    joffre
    Regular Contributor
    Robert,




    I have the following code:




    Sub CadCargos

    1 'Set most common sentence to a variable


    2 Set Cargos = Aliases.FPW5_CADCALC.Form1.MDIClient.cdCargos


    3 'I open the form


    4 Call Aliases.FPW5_CADCALC.Form1.MainMenu.Click("Tabelas|Cargos")


    5 'I check "Mensal" RadioButton


    6 Cargos.fraTipoSal.optMensal.ClickButton


    7 'I press "Next Code" button


    8 Cargos.btnProxCod.ClickButton


    9 'Types description


    10 Cargos.fraCargos.cboCargos.wText = ""


    11 'Types CBOs code


    12 Call Cargos.fraCargos.txtCBO.Keys("")


    13 'This value will always be 1


    14 Call Cargos.fraCargos.txtCodSind.Keys("1")


    15 'Press Save button


    16 Cargos.btnCadMod1.ClickButton


    Sub RemCargos




    On lines 10 and 12 I'll pick itens from one excel file to fill blank quotes. How will I do my loop and how will my lines will be after the code is ready to run?



    Supose that my Excel File has the following itens:

    Column 1 || Column 2

    Row 1.1 || Row 1.2

    Row 2.1 || Row 2.2

    Row 3.1 || Row 3.2

    Row 4.1 || Row 4.2

    Row 5.1 || Row 5.2



    Thanks.





    Obs.: I don't understand why does my posts have so many spaces between lines.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Now, one more doubt. As in the picture attached, what are the parameters that I have to pass to DDT.ExcelDriver!? It requires the path of my ExcelFile, requires a Sheet and 'UseACEDriver'. What is this sheet? And what is ACEDriver?




    The help file for DDT.ExcelDriver explains them both.http://smartbear.com/support/viewarticle/11915/  An Excel file contains multiple sheets, typically.  So, the "Sheet" parameter is the name of the sheet within the Excel file to use for the data.  The ACE driver is a specific driver to allow you to use Excel 2007 files.



    On lines 10 and 12 I'll pick itens from one excel file to fill blank quotes. How will I do my loop and how will my lines will be after the code is ready to run?




    Write your loop as described above.  Your call will look like this for line 10



    Cargos.fraCargos.cboCargos.wText = DDT.CurrentDriver.Value("Column 1")




    Line 12 will read



    Call Cargos.fraCargos.txtCBO.Keys(DDT.CurrentDriver.Value("Column 2")) 




    The tutorial that I linked to you before walks you through these kinds of tasks.  I'd strongly recommend you read the tutorial and walk through it as it describes these kinds of tasks.










  • joffre's avatar
    joffre
    Regular Contributor
    Oh... my Excel is on portuguese. Sheets means "Planilhas"... ^^



    Thanks. I think my problems about DDT are solved! Thank you a lot!