I've written a script for verifying that selecting a menu in my application displays the correct content. However, after I select the menu items, focus jumps back to the main window and the mouse repositions itself at (presumably) 1,1 on that main window; problems arise when the automation accidentally clicks in that position, which opens another window.
As best I can tell, the repositioning occurs at the .attach command. Is there a way to attach to a window/dialog box without the mouse moving? I've tried stepping through my code, but its hard to see when the focus changes.
<font class="small">Code:</font><hr /><pre> For Each MenuNavigation_ExcelData_Row In MenuNavigation_ExcelData_ActiveData
IEWindow("application = IEXPLORE.EXE caption = 'AdvancedMD*'", tpAttachNoWait).Attach
'Select the menu options
HTMLSpan("InnerText = '" & MenuNavigation_ExcelData_Row.GetString("Main Menu") & "'").Click 'Main menu
HTMLTD("InnerText = '" & MenuNavigation_ExcelData_Row.GetString("Sub Menu 1") & "'").Click 'First sub-menu
If MenuNavigation_ExcelData_Row.GetString("Sub Menu 2") <> "" Then 'This could be blank
HTMLTD("InnerText = '" & MenuNavigation_ExcelData_Row.GetString("Sub Menu 2") & "'").Click 'Second sub-menu
'Verify that the correct page is displayed
If IEWindow(MenuNavigation_ExcelData_Row.GetString("P age Name"), tpAttachNoWait).Exists = True Then
UserCheck "Menu Navigation", True, "The menu navigation was correct."
UserCheck "Page Title", True, "The correct page was displayed."
UserCheck "Page Title", False, "The correct page was NOT displayed. Expected: " & MenuNavigation_ExcelData_Row.GetString("Page Name")
Next </pre><hr />
AUT: Web app - Java/SQL
Using TestPartner since 2008
Using QTP since 2002