Sunday, April 19, 2009

How we can parameterize Descriptive Programming statements?

Open a new blank Notepad and type

<title>Hello World1</title>

And save it with .html extension. (I saved it as First.html under c:\)

Open another new blank notepad and type

<title>Hello World2</title>

And save it with .html extension. (I saved it as Second.html under c:\)

Open a new blank test in QTP and type the following code:

Set myBrowser = Description.Create()
myBrowser("opentitle").Value = "Hello " & DataTable.Value("A")

Also enter World1 and World2 in Cell A1 and A2 in Global Sheet.

Double click on First.html and Second.html in order to open them in Internet Explorer.

Make sure that both First and Second are visible and run the test.
Running the test will close both the browsers.

Above is a very small example that shows how we can data-drive a property value since the browsers have opentitle property values as “Hello World1” and “Hello World2” respectively. So we have used data table in this example to parameterize the values.

Also See:

Descriptive Programming Vs Object Repository
Descriptive Programming in QTP
Important Descriptive Programming Questions
Object Repositories in QTP