100% found this document useful (1 vote)
765 views

QTP - Getting Current Browser URL

This document discusses two ways to get the current URL in a browser using QuickTest Professional (QTP): 1. Using the GetROProperty("URL") method, which reads run-time object properties and supports getting the URL across browsers. 2. Using the "URL" property of the "Object", which accesses the Internet Explorer Document Object Model and provides more properties and methods but only works in Internet Explorer. Both methods can be used to retrieve the current URL opened in the browser. The GetROProperty method works across browsers while the DOM object provides more capabilities but only in Internet Explorer.

Uploaded by

api-19840982
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
765 views

QTP - Getting Current Browser URL

This document discusses two ways to get the current URL in a browser using QuickTest Professional (QTP): 1. Using the GetROProperty("URL") method, which reads run-time object properties and supports getting the URL across browsers. 2. Using the "URL" property of the "Object", which accesses the Internet Explorer Document Object Model and provides more properties and methods but only works in Internet Explorer. Both methods can be used to retrieve the current URL opened in the browser. The GetROProperty method works across browsers while the DOM object provides more capabilities but only in Internet Explorer.

Uploaded by

api-19840982
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

QTP - getting current browser URL

I'm going to show and explain how to get current URL which is opened in
a browser.
For example, how to get URL "http://motevich.blogspot.com" from the following
browser:

There are two solutions:

1. Using GetROProperty("URL") method (run-time object property)


2. Using "URL" property of "Object" (IE DOM Object)

Let's consider both variants.

1. GetRoProperty("URL") method (run-time object property)

GetRoProperty function reads properties of a run-time object in an


application.
If you open QTP Help on GetRoProperty function, you 'll see that this
function can work with all objects:

So, for example:


o to check whether a link is visible or not, use:
Browser("bname").Page("pname").Link("lname").GetROPropert
y("visible")
o to get a page's title, use:
Browser("bname").Page("pname").GetROProperty("title")
o to check whether a window is maximized, use:
Window("wname").GetROProperty("maximized")
o to get width of WebButton, use:
Browser("bname").Page("pname").WebButton("btname").GetROP
roperty("width")

Others properties are described in QTP Help.

In our case, to get URL of the current WebPage, we will use:

Browser("bname").Page("pname").GetRoProperty("URL")

This is a sample QTP script:

(Click the image


to enlarge it)

2. "URL" property of "Object" (IE DOM Object)

The sample syntax is:

Browser("bname").Page("pname").Object.URL

What is "Object" in the above statement?


Actually, this is Internet Explorer Document Object Model (DOM) Object.
You can read more about DOM here and here.
Also, I recommend to read this interested article on working with IE DOM
from Visual Basic.

Tip: You can use DOM Object when running QTP test on Internet
Explorer only!

To make the long story short, I can say that using Object property you can
get almost all elements and properties from Web page.

Thus, I use URL property of Internet Explorer's DOM Object.


All properties, collections, and methods of DOM Object are described in
this MSDN article.

Tip: The number of properties, accessed via DOM Object, is more


bigger, than properties accessed via GetROProperty method.

So, the result of above code is:

(Click the image


to enlarge it)

Summary:
Two ways were discussed:

1. GetROProperty("URL") (run-time object property)


2. "URL" property of "Object" (IE DOM Object)

GetROProperty method supports both IE & FireFox, but IE DOM Object


provides more accessible properties and methods.
Both can get URL of the current Web page.

You might also like