Forum Discussion

Lagencie's avatar
Lagencie
Frequent Contributor
6 years ago

Project Variable Table

Hello,

 

I have a question is there a way to create a permanent Table as Project Variable? 

 

I know there is a way to create tables as ComponentTable during runtime with this code:

 

if Project.Variables.VariableExists("ComponentTable"):
    # Get a reference to the variable
    t = Project.Variables.VariableByName["ComponentTable"]
  else:
    Project.Variables.AddVariable("ComponentTable", "Table")
    t = Project.Variables.VariableByName["ComponentTable"]

 

But this way I have to always fill it during runtime and I want it to be filled with fixed values - on Project Variable Layer, not on Keyword Test Layer, where I can create tables.

3 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    Persistent variable does not have an ability to store table type. Instead of what you can do, OnStartTest event handler you can just add the script that you mentioned. It will create that project variable whenever you start to run.

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      If you need something in a table to persist, my suggestion would be to create some sort of external file to read/write to.  Or an SQL database.  

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Yes, shankar_r is correct. Only Temporary variables of Table type can be created via code and those variables do not preserve their contents/structure created/modified from code.