Forum Discussion

DanH's avatar
DanH
Contributor
5 years ago
Solved

Can you change the data source used in a Data Driven Loop using a script?

I'm wanting to change the datasource (Excel spreadsheet) used in a Data-Driven loop.  The scenario is, I have some tests which work fine, but I would like to feed different data into them from an Excel spreadsheet:  The most straightforward way seems to be to create a number of different spreadsheets and use a script to decide which spreadsheet to use depending on trequirements.

  • Yes.  Question, though, is whether or you're doing Keyword testing or Script testing.  Script testing is easy... just make the excel file path in the ExcelDriver method  a variable and change the variable assignment.

     

    For Keyword testing, not quite so easy.   What I would do is put the loop in script code and call the keyword test within the loop.

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Yes.  Question, though, is whether or you're doing Keyword testing or Script testing.  Script testing is easy... just make the excel file path in the ExcelDriver method  a variable and change the variable assignment.

     

    For Keyword testing, not quite so easy.   What I would do is put the loop in script code and call the keyword test within the loop.

    • DanH's avatar
      DanH
      Contributor

      Great, thanks for the reply.  I'm in  and out of meetingts at the moment, but will have a play as soon as I can. 

       

      The current tests are KeyWord tests, and I'll look into calling the tests from a loop in a scrippted test.... I'm also wondering whether it might be worth simply converting the Keyword tests to script:  which might make it easier to change other aspects of the tests using scripts.