Forum Discussion

MW_Didata's avatar
MW_Didata
Regular Contributor
2 months ago
Solved

Use variable inside other vars default value

My Base URL has been changing a few times, Going over every item inside the namemapping to change the IP address to the website takes a while.

So I want to make my BaseURL inside the namemapping a variable.

To do this I found it's not possible to concat inside the namemapping

^ This doesn't work.

Then I thought lets just a var for each of the programs.

However I quickly found out that works for the entire run but not when running individual tests because those vars don't get set.

Is there any way to set the Default value with a variable and concat the appropriate link to it?

This is my current namemapping:

I want to set it like this or something similar:

Using the vars with a default value to also be able to run each test individually for debugging.

6 Replies

  • I've created a "helper" class, which is the first thing that gets initiated before any tests are executed. Within this class, I have a number of methods and properties, and these property values are initialised using Storages.INI. Modifying the settings.ini file, I can change my database source, browser, username, password etc. It's easy to maintain.

     

  • Using this method:

    Makes every program address available if the function is called in the run.

  • I found a great solution,

    By using Events onStartTest to run the Set_ProgramURLs function:

    this way every time a test is run it will set the variables.

     

    The only "issue" is that it gets run on every test in the executionplan, however since its just setting some variables it's probably okay.

    • MW_Didata's avatar
      MW_Didata
      Regular Contributor

      That would not work since you can't put variables inside the 'Default value' field.

      • Hassan_Ballan's avatar
        Hassan_Ballan
        Icon for Champion Level 1 rankChampion Level 1

        Any reason you need to maintain the IP address part of the URL? 

        I usually replace the URL protocol as well as the domain name with wild card to be able to run against multiple environments. In that case you would no longer need to make it a variable.

        You only need the path part of the URL protocol, domain, and query string are irrelevant, and you could run with */manage* as a URL.