Micro Focus QTP (UFT) Forums
Unable to close a 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 Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions)
+--- Thread: Unable to close a Window (/Thread-Unable-to-close-a-Window)



Unable to close a Window - Brian T. - 04-25-2012

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..


RE: Unable to close a Window - sshukla12 - 04-25-2012

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


RE: Unable to close a Window - Brian T. - 04-25-2012

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?


RE: Unable to close a Window - jesonvan - 09-21-2012

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



RE: Unable to close a Window - Ankesh - 09-24-2012

one alternate suggestion would be to

Code:
Browser("Additional Windows").Page("APRS : VIEW APPLICATION").Close



RE: Unable to close a Window - TesterJan - 04-25-2013

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



RE: Unable to close a Window - Staff - 07-05-2013

Please ensure to include your code between [code] tags while asking or replying to questions. I have done this for you for this time.