Forum Discussion

Deeksha_goyal's avatar
Deeksha_goyal
Contributor
10 years ago
Solved

How to make namemapping file variable

Hi All,



I have 5 environment where i need to run my automated test with different URL. for now i have clonned the scripts and changed the name mapping file.



But now if there is a change in my script. I need to update that in all 5 copies.



I was wondering if we can keep my name mapping file itself variable and configure at run time which file to use for a particular test run. This way i would be able to use one copy for all environments
  • Depending on how your "environments" are setup (domains possibly??), you can use the "OnStartTest" event hanler to set an environment variable to the URL stub for testing.  This way, you could set "http://urlOne.com/*" as the enviornment variable and then do a aqString.Replace(url, "/*", "/pageToDisplay.html") where you needed to reference the other pages.  Given the information you have provided, it's hard to say what an "environment" is, or how you could determine when you're in one of the five of them.

3 Replies

  • Hi - you could possibly use wildcards to describe the URL in the NameMapping - it depends if that would match all five.  Or you could add say an environment variable to each environment and read that - and set that to the URL in the NameMapping by using Project.Variables - i.e. don't have a constant value for the URL, but use a Project Variable
  • Depending on how your "environments" are setup (domains possibly??), you can use the "OnStartTest" event hanler to set an environment variable to the URL stub for testing.  This way, you could set "http://urlOne.com/*" as the enviornment variable and then do a aqString.Replace(url, "/*", "/pageToDisplay.html") where you needed to reference the other pages.  Given the information you have provided, it's hard to say what an "environment" is, or how you could determine when you're in one of the five of them.
  • Hi,



    You can also decouple url from NameMapping.Write a small function to invoke the browser with given url and then set the window invoked as Aliases.IE or Aliases.FF wichever browser you are using.





    -Neha