0

I am running some automated tests on an POS application where a large number of sales are entered using a for loop. During the test there are times where it is possible for the application window to lose focus, and when this happened we get a pop up window and this causes the test to stop.

I currently have a lot of checks in the code to look for this window after multiple steps in the loop, but each one I add adds time to the sale and slows the test down. Is there a way in python to constantly check for something like these windows.

To note I am using TestComplete and I have looked into the event handlers and it does not appear I will be able to use them due to how the application was developed.

1 Answers1

0

I recommend you try to use an interrupt schedule. The basic idea is that you trigger a function (in this case your function checking for unexpected windows) whenever some counter reaches a value.

If you don't need to check at very specific and short time intervals it is enough to use something like time.clock(). I you DO need the abovementioned there are libraries for that, specifically the signal module or the more advanced sched, which are both part of the standard library (as far as I know, Documentation of signal, Documentation of sched).

There are also other (external, non-standard) modules that can work, but sched and/or signal should be enough here.

Feel free to ask if any further question should arise.

This SO post might also help: real time interrupts in python

E. Staikov
  • 106
  • 8