How to get text of Status Bar from QTP?

How to get text of Status Bar from QTP?

When you work in QTP with Web applications, it is sometimes necessary to get a text of browser's status bar.
Let's see for example the following browser:

How to get text of Status Bar from QuickTest Professional?
There are two ways:
  1. Object.StatusText property of Browser object
  2. GetROProperty("text") method of WinStatusBar object

  1. Getting text of Status Bar using Object.StatusText property of Browser object

    To access text of Status Bar, we use Browser's Object object and its StatusText property.
    Browser("bname").Object is a reference to the Internet Explorer's DOM object. To be more precise, it's a reference to the Internet Explorer's IWebBrowser2 interface.

    Using Browser("bname").Object, you can access different methods and properties of IE, for example:

    #
    Statement
    Meaning
    1
    Browser("bname").Object.GoBackNavigates backward one item in the history list
    2
    Browser("bname").Object.LocationURLGets the URL of the page that is currently displayed
    3
    Browser("bname").Object.StatusTextSets or gets the text in the status bar for the object
    4
    Browser("bname").Object.ToolBarSets or gets whether toolbars for the object are visible

    So, our code is simpe enough:
    sText = Browser("QTP - How to get Status").Object.StatusText
    MsgBox sText
    And its result is:
    Note: Since we use Internet Explorer's IWebBrowser2 interface, we can use this solution win IE only. It doesn't work with FireFox. The next solution will be compatibe with both IE and FF.


  2. Getting text of Status Bar using GetROProperty("text") method of WinStatusBar object

    Status bar is a part of browser's window. There is a special class to handle it from QTP - WinStatusBar. We can get text of WinStatusBar using GetROProperty("text") method.

    So, I add Status Bar to QTP's Object Repository (OR):
    QTP Object Repository
    The final script is:
    sText = Browser("QTP - How to get Status").WinStatusBar("msctls_statusbar32").GetROProperty("text")
    MsgBox sText
    And its result is:
    Result of QTP script
    Note: This solution works correctly both for IE and FF, but it requires additional operations with Object Repository.

Summary:
Two approaches were shown.
Both do the same - they get text of Status Bar from QTP.

Which approach is prefferable?
Actually, it's up to you.
As for me, my choice is a compatibility. So, I prefer using of WinStatusBar object.


Related articles:


--
Dmitry

5 comments:

Anonymous said...

hi, thanx for script of load runner-how to verify web page content. but sir i am working using QTP can u guide me the same script "how to verify the web page content" using QTP. it will be greatfull. please meil me at my id ranjansingh83@gmail.com

vasu said...

awesome

Thanks,
Srini

mahesh said...

hi..
i got how to catch the status bar text from web application bbut can you please explain the same with window aaplication.

Dmitry Motevich said...

2mahesh,
Why don't you perform investigations and prepare such article on capturing of status bar text in Windows applications? :)
I will publish your results...

Anonymous said...

For thick client windows application also, you can get the status bar with the same code (a little change):

sText = Window("QTP Notes").WinStatusBar("msctls_statusbar32").GetROProperty("text")
MsgBox sText

The above code is for Windows Explorer status bar.