Micro Focus QTP (UFT) Forums
How to write DP for a pop up window which appears only during execution and changes - 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: How to write DP for a pop up window which appears only during execution and changes (/Thread-How-to-write-DP-for-a-pop-up-window-which-appears-only-during-execution-and-changes)



How to write DP for a pop up window which appears only during execution and changes - anushreebehura - 06-07-2012

Hi
I am using windows based application and QTP 10. In middle of the execution a pop up window comes up and I need to write a DP for that.
Problem is the pop up window does not comes up if we do the test manually and also its not fixed when it appears. So I cant use Object Spy for properties. Also the name of the dialog is different everytime it appears. Kindly suggest how I can write DP for this case.


RE: How to write DP for a pop up window which appears only during execution and changes - supputuri - 06-07-2012

[attachment=1008]Hi Anushree,

there are different ways we can handle this. But I think the best methodology is getting the hwnd of the popup window and then work on that.

Below is the simple code with sample windows application. I have attached the screenshot for better understanding.
Code:
'Step1: Simulate your action to bring the popup window
'Click on the OK button in Login window which will simulate the popup window.
Dialog("Login").WinButton("OK").Click
'Step 2: Get the HWND of the popup window (assuming that the popup window is the top most window)
'Declare the extern
extern.Declare micLong,"GetForegroundWindow","user32.dll","GetForegroundWindow"
'Get the top most window hwnd
hwnd = extern.GetForegroundWindow()
'Step 3: Assign the HWND value to the Object in OR.
'set the hwnd value in object repository
Dialog("TopWindow").SetTOProperty "hwnd",hwnd
'Step 4: Continue working with popup window as usual
'Highlight the top most window
Dialog("TopWindow").highlight
'get the runtime property value (based on your requirement)
msgbox Dialog("TopWindow").GetVisibleText()
msgbox Dialog("TopWindow").GetROProperty("regexpwndtitle")
'perform operation on the top most window objects.
Dialog("TopWindow").WinButton("OK").Click
Please let me know if you need any further help