Script To Automatically Close 'Active' Window
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.
Solved! Go to Solution.
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.
/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.
Thanks for your help, Alex!
@helpdesk, is this what you were looking for?
SmartBear Community and Education Manager
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.