Forum Discussion

sdruker's avatar
10 years ago

Running keywordtest using DDT Driver DriveMethod method


I read the article about ddt drivers:

 the DriveMethod method runs through all the records of the driver's table abd execute the routine passed to it as parameter.

I would like to pass to this method keywordtest instead of script. Is it possible?

  • Are you doing all your work in keyword tests or are you mixing scripts and keyword tests?

5 Replies

  • most of the tests are written as keyword tests.

    I'm trying to create flexible env for running the tests.

    (reading  writing and verifying values from\to excel files etc)

    The ddt drivers procedures are a mix of keywordtests and scripts, and should be generic as much as possible.

  • Marsha_R's avatar
    Champion Level 3
    Are you doing all your work in keyword tests or are you mixing scripts and keyword tests?
  • Marsha_R's avatar
    Champion Level 3
    We put whatever we need in the processing loop of the DDT.  See attached - does that example help?
  • I did very similar loop to the attached example,. but then I read  about the "DriveMethod" method which should iterates through all the records inside the ddt.

    I wondered that it might be nicer solution than the  loop that I did, but in the example they are running script using this method and I wanted to know if it possible to run also keywwords using that method and if yes what is the right syntax
  • Marsha_R's avatar
    Champion Level 3
    Well, DriveMethod can be used directly in a keyword test from Call Object Method in the menu.  Start with DDT and step through the wizard it from there.

    However, in the 56908 article, look at the end of the VB code example (or see below).  It's exactly what's in the keyword while loop example that I posted.  You define the driver and tell it what data source to use, then while the driver doesn't run out of data source records, do whatever is in the loop.  

    If your loop is similar to this, or to my example, then you are already doing DriveMethod.  It's just hidden in the keyword definitions.  

    Sub TestDriver

      Dim Driver


      ' Creates the driver

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

      ' Set Driver = DDT.ExcelDriver("C:\MyFile.xlsx", "Sheet1", True)

      Set Driver = DDT.ExcelDriver("C:\MyFile.xls", "Sheet1") 


      ' Iterates through records

      RecNo = 0

      While Not Driver.EOF()

        Call ProcessData() ' Processes data

        Call Driver.Next() ' Goes to the next record



      ' Closes the driver

      Call DDT.CloseDriver(Driver.Name)

    End Sub