Micro Focus QTP (UFT) Forums
Change of Enviroment - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Change of Enviroment (/Thread-Change-of-Enviroment)



Change of Enviroment - NancyNancy - 02-05-2011


How can I use the same scripts for a test in a different environment without changing the scripts line by line.


If you know the way, or have used, would you be able to share / explain in an elaborated way please


RE: Change of Enviroment - ksrikanth2k9 - 02-10-2011

Code:
Dim env
env=environment("OS")
msgbox env
If env="Microsofr Windows XP workstation" Then
{Your script here}
else
{Mention other condition}
End If

The condition maybe OS,User name,configuration etc.


RE: Change of Enviroment - supputuri - 02-11-2011

Hi Nancy,

You can use the
1) Environment variable : with URL
2) Use Global Sheet : To change the application URL
3) Use external file where you can specify the environment name and URL

I think this is the information what your are looking for..... If not let me know...


RE: Change of Enviroment - jsknight1969 - 02-16-2011

Maybe by "environment" you mean a development vs production area? Maybe a .net vs a .com?

If so, you can use Regular Expressions to remove the environment specific portions.

Code:
Browser("url:=.*myurl.*)

This code would have allow your browser to view any url that contained "myurl" regardless of what the rest of the url is.

www.myserver/myurl .... works
www.myurl.net/ ... works
www.myurl.com/ .. works
www.thisismyurl .. works

Hopefully you are using Descriptive Programming for all your testing. If you are using the object repository or just doing "record and run" scripts they will not be reusable in a different environment if there is even the smallest of changes.

hope this helps.


RE: Change of Enviroment - tdevick - 02-17-2011

We put all the dynamic information about our environment in an external file and use "Environment.LoadFromFile(fileName)" to load it into environment variables. We this for things like the URL of the test sever (it changes from time to time), product login information, account to log in to, etc. We have a global action "Login" that we use in every script that reads this environment file, starts the browser, goes to the test site, and logs in.