cancel
Showing results for 
Search instead for 
Did you mean: 

Script To Automatically Close 'Active' Window

SOLVED
Highlighted
Occasional 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 Hero]
____
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

Highlighted
Occasional 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 🙂

View solution in original post

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 Hero]
____
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

Highlighted
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

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
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.

Highlighted
Occasional 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 🙂

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors