URL Variables - 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: URL Variables (/Thread-URL-Variables) |
URL Variables - kevwhite79 - 03-02-2011 Hi, I'm very new to QTP so please help. I have created a number of QTP scripts and uploaded them to HPQC, connectivity is established and scripts can be played back ok. However, my intention is to run these scripts on multiple test environments now (same screens just log in via different URLs). So I wanted to link to an external (XML?) file that contains the URL information so that changing the URL in this file would point the scripts to the desired test environment. I'm not finding this easy to do. Can you give me some advice please on setting up the first few steps of the scripts to check the external file for the URL to use when IE loads. I have tried creating and using a User Defined Environment Variable without success :-( Thanks in advance for any help. PS If username and password can be stored in the file also that would be great. RE: URL Variables - tdevick - 03-02-2011 create an XML environment file in this format, and store it in where it can always be found on disk by your tests. You can have as many "<Variable>" tags as you want in your XML file. Each "<Variable>" tag must contain a "<Name>" and a "<Value>" sub-tags. The file must start with "<Environment>" and end with "</Environment>". Within that context, you can define whatever variables you want. In the example below, if the URL of your test server changes, you change the PRODUCT_URL tag's value. Code: <Environment> Code: 'get the currently loaded external file name; blank if not file loaded We have been keeping our xml file in the QC repository under "Resources", where function libraries are stored. I created a sub-directory there named "xml files" and store our xml file there. That way it is under source control so you can see the change history and you can revert to a previous version if you want. doing that required a little more work: Code: fileName=Environment.ExternalFileName "downloadEnvironmentVariablesFile" is a function we wrote and is defined in function library file "Quality Center Functions.qfl": Code: Option Explicit Hope this helps. RE: URL Variables - kevwhite79 - 03-03-2011 Thank you very much. I will try this tomorrow. |