Forum Discussion

WillyPete's avatar
WillyPete
Contributor
8 years ago

Would like to use a variable for the excel spreadsheet in a keyword data driven loop

I am trying to create a keyword test that includes a data driven loop to test the outputs for an online application.  The user first selects the country they reside in and based on this selection they are presented with the products available for their country.  I would like to be able to direct the data driven loop to use a particular excel spreadsheet for the inputs and verification values based on the country selected. I have a keyword test currently which will use the same excel spreadsheet regardless of the country selected.

Thanks for any help.

5 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    What we did in a similar case is keep all the data in one spreadsheet but each country has a different sheet.  Then you keep the path to the excel file in a variable or a parameter.   Once you've read the country name from the user input, then take that string and concatenate it to the end of the excel file name and that gives you the path for the specific sheet for the country.

  • NisHera's avatar
    NisHera
    Valued Contributor

    Do you have input counties also in XL sheet?

    or you input country (by hand) as Marsha_R described? 

     

    If it's first case you have to rearrange XL such that column A would represent country,  rest of columns data  inputs and verification values as your usual spreadsheet. In this case you can design like if new row country = = previous row country no need to enter the country. have to keep previous row country in a variable

     

     

    • WillyPete's avatar
      WillyPete
      Contributor

      I have the countries in one spreadsheet and the inputs and verification data in separate spreadsheets.  The reason for this is that countries A, B and C have the same input values while C, D, E have a different set of inputs and so on.  So depending on the country I just want to point the keyword test to the desired spreadsheet but I am not a programmer so right now I am limited to using what I can find in the keyword prepackaged commands and wizards.

      • NisHera's avatar
        NisHera
        Valued Contributor

        In sort term you can get duplicated test, one for country A ,B, C and other one for D,E,F ...so on.

         

        But your scenario can be covered by single test with little bit of additional logic+programming.

        You can not open two (or rather nested ) DDT loops at a given time. 

         

        Automated testing involves programming essentially. even keyword tests uses basic programming logic. If you are going to stay with automated testing learn some basic programming concept any try hands on with TC. Good thing is no need to be a full stack developer. Can start with simple basics and progress on.