[TIP] Python GUI testing

Gary Bernhardt gary.bernhardt at gmail.com
Sat Apr 2 18:23:05 PDT 2011


On Sat, Apr 2, 2011 at 12:16 PM, Geoff Bache <geoff.bache at gmail.com> wrote:
> Gary and Nagappan - interesting that you're reaching for
> platform-level tools (Linux/Mac) rather than toolkit-level tools (GTK,
> QT etc). One thing I wondered about these kind of tools is whether you
> can refer to "widget names" at all (most toolkits have a "setName"
> method) in the tests. I guess those might not be accessible from
> outside the application?

With appscript (which is just AppleScript), you can use the System
Events interface to query any application's view hierarchy by whatever
attributes you want. Most of the things I said were "click the button
with title X", "click the menu item with title Y", etc.

> Also, don't you end up with many more
> synchronisation issues, because a tool running outside the process
> can't tell when the GUI thread is idle and ready for action again?

I can't speak for other technologies, but System Events via
AppleScript blocks. You're inserting events directly into the
application's message queue and your call doesn't return until the
event has been handled. I never had any synchronization problems,
which was surprising.

-- 
Gary
http://blog.extracheese.org



More information about the testing-in-python mailing list