Micro Focus QTP (UFT) Forums
Java Popup Focus Lost - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Java Popup Focus Lost (/Thread-Java-Popup-Focus-Lost)



Java Popup Focus Lost - davey2582 - 12-29-2011

My application is java swing and uses JidePopups containing java menus which QTP recognises as JavaMenu objects.

In order to close a tab in the application I right click on it and have to select the "Close" JavaMenu item from the popup. My code is as follows:

Code:
JavaWindow("ldnGUI").JavaTab("TdiGroup").Click 10,10,"RIGHT"
JavaWindow("ldnGUI").JavaMenu("label:=Close").Select

However, it seems that following the execution of the right click command, focus is lost from the popup when QTP goes to the next code line, and because focus is lost the popup disappears. When QTP comes to execute the selection of the Close menu item, it is no longer there and the action doesn't take place.

Has anyone come across this before with java popups or more specifically, JidePopups?

Strangely, when I record these actions and play them back it works fine, but I can't use the recorded versions due to the way my scripts have to be set up.




RE: Java Popup Focus Lost - ravi.gajul - 12-30-2011

Please try the below code
Code:
Setting.WebPackage("ReplayType") = 2 ' This lines changes the run mode as Analog
JavaWindow("ldnGUI").JavaTab("TdiGroup").FireEvent "onclick",10,10,micRightBtn
wait(2)
Set WshShell = CreateObject("WScript.Shell")
itemIndex=5<Please change this>  'index of the close item

For i = 1 To itemIndex
WshShell.sendkeys "{DOWN}" 'Navigate to the option
Next
WshShell.sendkeys "{ENTER}"
Set WshSEll = nothing



RE: Java Popup Focus Lost - davey2582 - 01-03-2012

Hi Ravi,

Thanks very much, I had to tweak the posted code a little, and I can make an assumption that the Close menu item is the first on the popup list, so my final code is:

Code:
Setting.WebPackage("ReplayType") = 2
JavaWindow("ldnGUI").JavaTab("TdiGroup").Click 10,10,"RIGHT"

wait(2)
Set WshShell = CreateObject("WScript.Shell")

WshShell.sendkeys "{ENTER}"
Set WshSEll = nothing

This should help me solve a whole bunch of my popup issues so your response is much appreciated.

David