Forum Discussion

sohailalam2696's avatar
sohailalam2696
Contributor
3 years ago
Solved

Variables declarations based on environment

I have a webservice with 3 environments (UAT, PROD & DEV). For each seperate environment I use variables like; username: ${#Project#Username} password: ${#Project#Password} So now, what should I ...
  • rraghvani's avatar
    2 years ago

    I agree, the question doesn't make sense!

     

    For example, I have the following web environments DEV, UAT, REG, PS and P. The URL for each environments looks like this,

     

    http://dev.smartbear.com 

    http://uat.smartbear.com 

    http://reg.smartbear.com 

    https://ps.smartbear.com 

    https://www.smartbear.com 

     

    I have an INI file, that stores the URL, username and password,

    ; Defines the environment to be used
    
    [Settings]
    URL=http://uat.smartbear.com
    Username=tester1
    Password=letme1n
    

    I read the INI file, and pass the appropriate parameters to my script which will then launch the browser,

    var ini = Storages.INI("C:\\settings.ini");
    
    // Reads URL
    var url = ini.GetSubSection("Settings").GetOption("URL");
    Browsers.Item(btChrome).Run(url);
    
    // Etc

    I can modify the INI file, without making changes to the script, to automate the required environment.