Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Advanced UFT 12 for Test Engineers Cookbook
  • Table Of Contents Toc
Advanced UFT 12 for Test Engineers Cookbook

Advanced UFT 12 for Test Engineers Cookbook

4 (3)
close
close
Advanced UFT 12 for Test Engineers Cookbook

Advanced UFT 12 for Test Engineers Cookbook

4 (3)

Overview of this book

This advanced cookbook is designed for software testers and engineers with previous automation experience and teaches UFT (QTP) developers advanced programming approaches. Knowledge of software testing and basic coding (with VBScript in particular) and familiarity with programming concepts are prerequisites.
Table of Contents (13 chapters)
close
close
12
Index

Using a configuration file to manage test environments

As shown in the previous recipe, it is possible to read variable values from an .ini file. We will show how to define several environments within such a file and load the input data for the current environment during runtime.

Getting ready

Follow the same steps stated in the Getting ready section of the Reading values from an INI file recipe.

How to do it...

Create a new file with the name QA-env-settings.ini. Enter the following entries to create three sets of parameters corresponding to three test environments QA1, QA2, and QA3:

[QA1]
InputDataSrc= "RegressionData1.xls"
Username  	= "user1"
URL       	= "http://www.url1.com"
Description = "Data for QA1 environment"

[QA2]
InputDataSrc= "RegressionData2.xls"
Username  	= "user2"
URL       	= "http://www.url2.com"
Description = "Data for QA2 environment"

[QA3]
InputDataSrc = "RegressionData3.xls"
Username  	= "user3"
URL       	= "http://www.url3.com"
Description = "Data for QA3 environment"

In our test, we will load the input data based on the value of the Environment variable QA_ENV, which will take one of the following environments: QA1, QA2, or QA3. Before running the test, ensure that the variable exists, and provide the value for the required testing environment (see the Storing data in the Environment object recipe). Therefore, our code in Action1 will look like the following code snippet:

Dim sDataSourcePath, sURL, sUsername

oExtern.GetPrivateProfileString(Environment("QA_ENV"), _
"InputDataSrc", "", sDataSourcePath, 255, _
"QA_env_settings.ini")

oExtern.GetPrivateProfileString(Environment("QA_ENV"), _
"InputDataSrc", "", sURL, 255, "QA_env_settings.ini")

oExtern.GetPrivateProfileString(Environment("QA_ENV"), _
"InputDataSrc", "", sUsername, 255, "QA_env_settings.ini")

DataTable.Import(sDataSourcePath)

How it works...

We retrieve the value of the QA_ENV Environment variable, and accordingly load the values of the variables in the corresponding section in the .ini file. The value of the InputDataSrc key within the corresponding section is then retrieved (note that the parameter is passed by reference and filled by the target method) and is used to import the Excel file (as you can see in the Importing an Excel file to a test recipe) that contains the input data for the given testing environment.

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Advanced UFT 12 for Test Engineers Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon