How to wait for Windows to disappear or get active
Posted: Tue Sep 04, 2007 5:45 pm
I want to use Ranorex Python to automate testing of E-Mail clients.
I am starting with Outlook Express.
One important point for this seems to be a method to wait for windows to disappear (e.g. if I send an E-Mail I have to wait until the Message window goes away...)
I tried to use the ControlGetState() API for this, but this seems not to work
correctly. Although I can see that the 'New Message' Window is still there,
the state for this seems to be 'CONTROL_UNAVAILABLE'.
Here is the code snippet for this:
The output is:
state:-0x1
message Form unavailable
repeatedly...
In what cases will the state be -1?
Are there any known issues with this or how would you check for the existence or non existence of Controls/Windows which existed before?
I have tried AutoIt before, which had some 'waitXXX' functions.
But I like the Ranorex strategy of not inventing an own scripting language,
but using a powerful existing one like Python much more...
I am starting with Outlook Express.
One important point for this seems to be a method to wait for windows to disappear (e.g. if I send an E-Mail I have to wait until the Message window goes away...)
I tried to use the ControlGetState() API for this, but this seems not to work
correctly. Although I can see that the 'New Message' Window is still there,
the state for this seems to be 'CONTROL_UNAVAILABLE'.
Here is the code snippet for this:
Code: Select all
className = 'ATH_Note'
self.messageForm = Ranorex.FormFindClassName(className)
if self.messageForm == 0:
raise RanorexError, 'New message Form not found'
#Fill some fields in message form
#Press Send button
#In our test case message will not be sent yet
# e.g.because of errors
for i in range(NUMBER_OF_RETRIES):
Ranorex.Sleep(100)
messageState = Ranorex.ControlGetState(self.messageForm)
print 'state:' + hex(messageState)
if messageState & Ranorex.CONTROL_UNAVAILABLE:
print 'message Form unavailable'
else:
print 'message Form still existing'
state:-0x1
message Form unavailable
repeatedly...
In what cases will the state be -1?
Are there any known issues with this or how would you check for the existence or non existence of Controls/Windows which existed before?
I have tried AutoIt before, which had some 'waitXXX' functions.
But I like the Ranorex strategy of not inventing an own scripting language,
but using a powerful existing one like Python much more...