Micro Focus QTP (UFT) Forums

Full Version: Unable to close a Window
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a web application and in that application there are links to open other windows.

I have a situation where QTP will click the link and open the window but will not click the Close button in the newly opened window to close it.

The Close Button (Link) is in the Object Repository and using the Opbject Repository Manager I can locate the Close Button (link) in the newly opened window and I can locate the Close Button (link) in the Object repository...

Here is the code I currently have that opens the window by clicking on the View link and then to close the window by clicking the Close Button (link) in the window to close it and then it repeats for another link...

Code:
Browser("Access Provisioning Request").Page("Confirm Application Access").Link("View").Click
Browser("Additional Windows").Page("APRS : VIEW APPLICATION").Link("Close").Click
Browser("Access Provisioning Request").Page("Confirm Application Access").Link("View_2").Click
Browser("Additional Windows").Page("APRS : VIEW APPLICATION").Link("Close").Click
Help...I do not understand why this window is not closing..
Hi,

Since this is a web application and page needs time to load use sync function to first let the page opens properly and then try to close the page, it should help u.

Regards,
Sankalp
Sankalp

Thanks for the reply...a little refresher what is sync function?

Sankalp

I tried the Sync....but it still does not close the window....any other suggestions?
please try the following

Code:
Browser("Access Provisioning Request").Page("Confirm Application Access").Link("View").Click
Browser("Additional Windows").Page("APRS : VIEW APPLICATION").Link("Close").Click
Browser("Access Provisioning Request").Page("Confirm Application Access").Link("View_2").Click
' ####added script From ###
Browser("Access Provisioning Request").Page("Confirm Application Access").RefreshObject
' ####added script End ###
Browser("Additional Windows").Page("APRS : VIEW APPLICATION").Link("Close").Click
[hr]
Please try the following

Code:
Browser("Access Provisioning Request").Page("Confirm Application Access").Link("View").Click
Browser("Additional Windows").Page("APRS : VIEW APPLICATION").Link("Close").Click
Browser("Access Provisioning Request").Page("Confirm Application Access").Link("View_2").Click
' ####added script From ###
'Browser("Additional Windows").RefreshObject
'Browser("Additional Windows").Page("APRS : VIEW APPLICATION").RefreshObject
Browser("Additional Windows").Page("APRS : VIEW APPLICATION").Link("Close").RefreshObject
' ####added script End ###
Browser("Additional Windows").Page("APRS : VIEW APPLICATION").Link("Close").Click
one alternate suggestion would be to

Code:
Browser("Additional Windows").Page("APRS : VIEW APPLICATION").Close
Try This it worked for me

Code:
hWnd = Browser(BrowserName).GetROProperty("hwnd")      
hWnd = Browser("hwnd:=" &hWnd).Object.hWnd                                  
Window("hwnd:=" & hWnd).Activate  
Browser("hwnd:=" & hWnd).Close
Please ensure to include your code between [code] tags while asking or replying to questions. I have done this for you for this time.