Let's see for example the following browser:
How to get text of Status Bar from QuickTest Professional?
There are two ways:- Object.StatusText property of Browser object
- GetROProperty("text") method of WinStatusBar object
- 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.GoBack Navigates backward one item in the history list 2 Browser("bname").Object.LocationURL Gets the URL of the page that is currently displayed 3 Browser("bname").Object.StatusText Sets or gets the text in the status bar for the object 4 Browser("bname").Object.ToolBar Sets or gets whether toolbars for the object are visible
So, our code is simpe enough:sText = Browser("QTP - How to get Status").Object.StatusTextAnd its result is:
MsgBox sText
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. - 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):The final script is:sText = Browser("QTP - How to get Status").WinStatusBar("msctls_statusbar32").GetROProperty("text")And its result is:
MsgBox sText
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:
- QTP - How to get current browser's URL
- QTP VIDEO - How to capture dynamic text
- QTP VIDEO - How to run QTP test from command line
- QTP - How to capture tool tip?
- QTP Descriptive programming - processing images
- How to close all Browsers? - QTP Descriptive Programming
- How to minimize/maximize QTP window
- All QTP visual tutorials
--
Dmitry
5 comments:
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
awesome
Thanks,
Srini
hi..
i got how to catch the status bar text from web application bbut can you please explain the same with window aaplication.
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...
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.
Post a Comment