QTP - getting current browser URL

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)

    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:
    • to check whether a link is visible or not, use:
    • to get a page's title, use:
    • to check whether a window is maximized, use:
    • to get width of WebButton, use:
    Others properties are described in QTP Help.

    In our case, to get URL of the current WebPage, we will use:
    This is a sample QTP script:
    (Click the image to enlarge it)

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

    The sample syntax is:


    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.

    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.

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

Related articles:

Have you got interested materials or your own thoughts on QTP (QuickTest Professional)?
Let's share them and help each other to improve our skills and knowledge!
You can send them to my email: Dmitry Motevich's email

Thank you in advance, dear readers.

Dmitry Motevich


Anonymous said...


It is really helpfull to have these small programs which give us an insight of scriting manually. I found you site today I managed to go through all articles. They are very brillient & it helps a lot for beginners like me. I have few requests for you.
1) As you have suggested 10 steps to become QTP GURU, could also please come up with such things to master LoadRunner Scripting
2) Also could you please publish articles for scripting manually with simple programs (a) QTP (b) Load Runner - i have managed to script for QTP very small programs but for Load Runner I am still trying to program from scratch. I just have no idea from where to start
(3) Regarding LoadRunner, I have few questions in monitoring.
(a) what effect does apache max clients settings have on system as a whole? - I know that it sets the maximum number of users for sessions but have no idea of this inner architecture. What are other the parameters(like max client settings, tomcat instances, keep alive from load balancer). I here these stuff but has no idea from where to start to get indepth knowledge of these. Could please provide an overview of these terms & how do they relate with monitoring. Also Could you please brief up about what actions should be taken if find issues with memory being used up, %cpu crosses 75

This will help us a lot & i thank you from the bottom of my heart for giving us your valuable knowledge and time on these tools.

I will be waiting for your next posts.....

Dmitry Motevich said...

1) Yes, I put this article into my "queue"
2) Hm... Could you suggest me topics for such small articles for QTP & LR?
3) Please send your questions to LoadRunner group

Anonymous said...

Hi Dmitry,

Thanks a lot for your great work. It helps people like me who are looking forward to learn QTP.


Anonymous said...

Thank You Dmitry. You are doing a great job.