Ranorex

How to wait for Windows to disappear or get active

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexPython
View previous topic :: View next topic  
Author Message
gkring



Joined: 04 Sep 2007
Posts: 5

PostPosted: Tue Sep 04, 2007 6:45 pm    Post subject: How to wait for Windows to disappear or get active
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:
Code: click into code to enlarge

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'

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...
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Tue Sep 04, 2007 8:40 pm    Post subject:
It seems to be a problem with ControlGetState() if the control is a top level window.
Please use the function with a child control of the form:

Code: click into code to enlarge
button=Ranorex.FormFindChildControlName(form,'button1')
for i in range(NUMBER_OF_RETRIES):
    Ranorex.Sleep(100)   
    messageState = Ranorex.ControlGetState(button)
    print 'state:' + hex(messageState)
    if messageState & Ranorex.CONTROL_UNAVAILABLE:
         print 'message Form unavailable'
    else:
         print 'message Form still existing'


or use the position property of the form:

Code: click into code to enlarge
for i in range(NUMBER_OF_RETRIES):
    Ranorex.Sleep(100)   
    location = Ranorex.ControlGetPosition(form)
    if location == None:
         print 'message Form unavailable'
    else:
         print 'message Form still existing'

Jenö
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
gkring



Joined: 04 Sep 2007
Posts: 5

PostPosted: Wed Sep 05, 2007 10:17 am    Post subject:
Thank you!
I have tried it with your 2nd proposal and this works.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexPython All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum