Forum Discussion

vondie's avatar
vondie
Contributor
9 years ago
Solved

Accessing Local Variable from a Data Driven Loop for Run Script Routine

Hi everyone! I couldn't find any other posts that were attempting what I am trying to accomplish.

 

My team's end goal is to have tests that do not need to be updated one by one for each test.The majority of our tests are being created as Keyword Tests and we are using the Run Script Routine Test Action for checkpoints (writing scripts in Python). What I am hoping to do to accomplish this goal is create a Data Driven Loop within the Keyword test, add the data from a CSV file, then reference these values in the Script Routine for comparison.

 

Example: We are using a system that adds clients. There are fields for Client Name, Client Address, Client Phone Number, etc. I have a CSV file containing 5 rows of data to loop through so it will add 5 clients. I added the Run Script Routine Test Action to the end of the test, outside of the loop. My current issue is that I cannot access these variables within the Script Routine because they are considered Local Variables. I want to have a variable within the script routine that would take the value from the Keyword test it was called from. 

 

I have not been able to figure out how to make this work. I want to do DDT so we can swap out the CSV files easily without having to go back and edit a bunch of variable values. Any help is appreciated. 

 

Thanks! 

  • vondie's avatar
    vondie
    9 years ago

    I figured it out, and in hindsight it was pretty simple. 

     

    The syntax looks like this: 

    "KeywordTests.Test_Name.Variables.DDL_Data["textboxClientName"]"

10 Replies

    • vondie's avatar
      vondie
      Contributor

      I don't see a process in that document that details how to convert and/or create Data Driven Loop variables as Project level variables. I have read most of the support documentation and what I have found on Google and I still can't figure out the best route. Is this possible? 

      • Marsha_R's avatar
        Marsha_R
        Champion Level 3
        When you choose a variable in a test, all the project variables are listed along with the local ones. You can choose it in there. If there aren't any listed, you need to go to the Variables page for your project and add them.