cancel
Showing results for 
Search instead for 
Did you mean: 

Script To Automatically Close 'Active' Window

SOLVED
New Contributor

Script To Automatically Close 'Active' Window

Hi all,

 

I have another question that may sound silly. The application I am testing will open patient records in 2 different ways, half will be maximised view and the other half is a minimised view. Both views have a 'Minimise', 'Maximise' and 'Close' button. 

 

My issue is when setting up the automated tests I run into problems as sometimes the window will be maximised and others minimised so when I go to close the window the test case will fail as it is looking for the 'Close' function to be in a specific spot which it is not.

 

What I was wanting to do it run a script to close the window regardless of where it is place on the screen. I figured I could do this using the 'Run Code Snippet' feature but unfortunately, I am not a coder and the developers we use are through an external company. I tried googling and searching on this forum to see if there was a snipit of code for a Microsoft.Net program to execute the close button but I am not finding anything too helpful.

 

I was hoping someone might be able to point me to some information that may help me, If more information is needed or screenshots are needed please let me know.

 

Thank you and I hope my query makes sense. 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Hero

Re: Script To Automatically Close 'Active' Window

Hi,

 

I assume that you are working with a desktop application...

Usually, desktop windows have .Close() method that closes them. Check this with Object Browser.

Alternatively, you may send keys combination to the window that closes it. Usually this is Ctrl-F4 or Ctrl-W.

Both approaches should close the target window without the necessity to click its Close button.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
New Contributor

Re: Script To Automatically Close 'Active' Window

Thank you very much - Control F4 closes any active window within the application.

 

I appreciate the response Smiley Happy

4 REPLIES 4
Highlighted
Community Hero

Re: Script To Automatically Close 'Active' Window

Hi,

 

I assume that you are working with a desktop application...

Usually, desktop windows have .Close() method that closes them. Check this with Object Browser.

Alternatively, you may send keys combination to the window that closes it. Usually this is Ctrl-F4 or Ctrl-W.

Both approaches should close the target window without the necessity to click its Close button.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Community Manager

Re: Script To Automatically Close 'Active' Window

Thanks for your help, Alex!

 

@helpdesk, is this what you were looking for?

---------
Tanya Gorbunova
SmartBear Community Manager

Join the September Hub-bub to show off, learn and win
Occasional Contributor

Re: Script To Automatically Close 'Active' Window

Hello,

 

Maybe you can use this code here https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/window-and-process/te... choose the languange in which your project is and instead run code snippet use run script routine.

Hope this helps.

 

 

i'm sorry, didn't understand correctly, you want to close a window which is part of your application not another app that is called from the first one. My bad.

New Contributor

Re: Script To Automatically Close 'Active' Window

Thank you very much - Control F4 closes any active window within the application.

 

I appreciate the response Smiley Happy

New Here?
Join us and watch the welcome video:
Join the September Hub-bub to show off, learn and win