Tag Archives: Windows

I have been waiting write something about this for a while now. And here i am. I have just kinda of made myself familiar with this. There is a whole lot of documentation on Win32::GUITest package distributed with Perl, or i suppose it is. If not you can find by using Google(should i say that).

Why should you read Win32::GUITest?
> enthought.guitest modulde is a rewrite of the Win32::GUITest.
> There isn’t any good documentation/tutorial/reference on enthought.guitest anyway.

To twist the blog around a bit i will talk about the downsides of enthought.GUITest…

  • with enthought.guitest you need different script for different platforms.
  • You need to use too many sleep statements, as the WaitForReady is not available in the python version, to wait for a window operation to complete before you carry out the next operation. This is purely on your gut feel.
  • If you have not developed the GUI application yourself, it difficult to identify the Control ID of the sub-windows to the application, you could use Spy++ or any other similar tool, to get it. But still it did not work for me.
  • Though it is used for a pure vanilla testing of your GUI but if think you could spend a lot time, you could sit down and explore immaculately what you could do.

Now this is where you could find the enthought.guitest for your application.

  1. Linux
  2. Windows

In the same tree somewhere you could find the Mac as well. If you figure out how you tested the gui apps on Mac please leave a comment.

What do you do once you have downloaded the egg?

Extract the files. The directory will be called something like enthoughtXXXXXXX… I renamed it to my convinience to enthought.quitest.linux. Now i placed all my scripts inside for ease of running. One the simplest script is given below and its fail intuitive. This link give you a fair idea about how to do more than this on linux.

from enthought import guitest
from time import sleep

guitest.StartApp("gedit")
win = guitest.WaitWindowViewable("gedit")
guitest.SendKeys("Hello sam")

guitest.SendKeys("%(f)q")
sleep(1)
guitest.Sendkeys("{TAB}~")

What does the script do?

  1. Starts an application.
  2. Waits for the application to render itself.
  3. Sends the keyboard input “Hello sam” to the application
  4. Send Alt-F + Q to the application to quit.
  5. Sends the TAB and ENTER keys to the confirmation window.

Now as i said the same script cannot be run on windows, by just changing “gedit” to “notepad”.  It would look something like this…

from enthought.guitest import *
import os
from time import sleep

p = Popen("notepad.exe")

note_win = WaitWindow("Notepad",wait=10)
sleep(1)
SetForegroundWindow(note_win[0])
sleep(1)
SendKeys("Hello")
sleep(1)

SendKeys("%(f)x")
sleep(1)

SendKeys("{TAB}")
SendKeys("~")

These are the some operations as above. But you could notice that there has been some function call differences. If you have not developed the application that you are testing and the devloper is reluctant to give off the Control ID’s. You could do take the screen shot of the application and determine the relative pixel locations of the button or other controls and then make a gut feel decision of the operation times and apply sleeps appropriately and then emulate the mouse clicks.