Sunday, April 19, 2009

How we can parameterize Descriptive Programming statements?

1.
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:\)

2.
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:\)

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

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

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



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

6.
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