Micro Focus QTP (UFT) Forums
QTP hangs on handling error window - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: QTP hangs on handling error window (/Thread-QTP-hangs-on-handling-error-window)



QTP hangs on handling error window - dtamilarasan - 06-04-2013

My Requirement: When i click on a button in a dialog box, a window should come where as i need to click on OK button. Below is the code
**********************************
Code:
JavaWindow("My Teamcenter - Teamcenter").JavaWindow("My Teamcenter_Newdesign").JavaDialog("Remote Export Options").JavaTab("JTabbedPane").Select "Advanced"
JavaWindow("My Teamcenter - Teamcenter").JavaWindow("My Teamcenter_Newdesign").JavaDialog("Remote Export Options").Activate              
JavaWindow("My Teamcenter - Teamcenter").JavaWindow("My Teamcenter_Newdesign").JavaDialog("Remote Export Options").JavaButton("<<").click
' For loop to handle the window which occurs multiple times
Set objUnableWdw = JavaWindow("My Teamcenter - Teamcenter").JavaWindow("Shell").JavaWindow("Unable To Include Relation")
For i=0 to 10

If objUnableWdw.Exist(2) Then
    objUnableWdw.Activate
    objUnableWdw.JavaButton("OK").Click
else
    Exit For
End If

'**********************

In the above code, when I click on "<<" button, QTP gets hanged. If I handle that error window manually, the issue not happening.
Please advise how to handle this


RE: QTP hangs on handling error window - basanth27 - 06-04-2013

Do not use the For Loop. Instead use the below code per the instructions i have written below,
Code:
Set fso = CreateObject("WScript.Shell")
While fso.AppActivate("Your Window Name") = FALSE
wscript.sleep 1000
Wend
fso.SendKeys "a", True

fso.SendKeys "N", True

wscript.sleep 7000

While fso.AppActivate ("Your Window Name") = FALSE
wscript.sleep 1000
Wend

fso.SendKeys "N", True

How to use:
1. Save the above code as dialoghandler.vbs on your c:\ drive.
2. Be sure to modify the code to replace the window title or name.
3. Replace the appropriate keystrokes you need to send for the dialog. [ for eg :you may need to press "Enter" which inturn actually clicks on "OK" or "cancel" button.
4. Just before the line on QTP where the code executes and freezes QTP, enter this code,
SystemUtil.Run "C:\Windows\System32\Wscript.exe", "C:\dialoghandler.vbs"