Forum Discussion

sohailalam2696's avatar
sohailalam2696
Contributor
2 years ago

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 do when like I change from UAT to PROD, it automatically calls the Username and PW of PROD.

Thanks


  • So now, what should I do when like I change from UAT to PROD, it automatically calls the Username and PW of PROD.

     


    This part doesn't make sense. Are you saying that when you change from UAT from PROD, it is still using the UAT information?

     

    I would forcibly log out at the end of each environment test and then log in again with the next one. Perhaps you have a loop for the test? Then log out at the end of the loop and check the next environment.

     

    If you are still stuck, please post a screenshot of your test so we can see the details. It's hard to help when we have to guess.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    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.