Each page of my website has a help file associated with it. When a user selects the Help icon (which is a "?"), a new browser window opens up that contains the help information. The size of this second window is preset and is smaller than the browser window the website is displayed in. The only way for the user to close the help file is to left click on the "X" button in the top right corner of the window.
For each page on the website, the QTP script verifies the "?" button correctly displays the help file and then checks the text contents of the help file to verify the correct help information is displayed. The last step for this part of the script is to close the help file browser window. Once the help file is closed, the script continue testing other areas of the page.
When I playback the script, its a crapshoot that it will execute properly. Sometimes it will successfully close the help file browser window, thus allowing the rest of the script to execute. Sometimes instead of closing the help file browser window, it erroneously closes the browser window the main application is running in. When this occurs, the rest of the script fails to execute. Let me add that when the help file window is open, it is the active window. The top bar of the window is blue, while the top bar in the main browser window is gray.
I tried your recommendation but the script failed. In expert view, the line where the help file browser window is supposed to close is:
I tried Browser("PageName", "index:=0").close
& Browser("index:=0").close but the script failed for both changes.
In the Object Properties for the main browser window, the "creationtime" value is 0. For the help file browser window, the "creationtime" value is 1. I've looked through the QTP User's Guide to see if there is a way to specify which browser to close by referencing the "creationtime" value but so far haven't found anything yet.
QTP is bit frigle sometimes in Browser identification because of smartidentification, you can do one thing
Open the Object repository of the script and select the Browser objects in it and uncheck Enable Smart Identification which will give more reliable results.