Monday 24 March 2014

How to get current browser URL in QTP

There are two ways:
 1.  Using GetROProperty("URL") method (run-time object property)
       2. Using "URL" property of "Object" (IE DOM Object)
Using GetROProperty("URL") method (run-time object property)

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

So, for example:

  • To check whether a link is visible or not, use:
    Browser("bname").Page("pname").Link("lname").GetROProperty("visible")
  • To get a page's title, use:
    Browser("bname").Page("pname").GetROProperty("title")
  • To check whether a window is maximized, use:
    Window("wname").GetROProperty("maximized")
In our case, to get URL of the current WebPage, we will use:
Browser("bname").Page("pname").GetRoProperty("URL")

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

The sample syntax is:

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


No comments:

Post a Comment