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:
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.
- 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:
And its result is:Note: This solution works correctly both for IE and FF, but it requires additional operations with Object Repository.
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.
- 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