[TIP] Python GUI testing

Geoff Bache geoff.bache at gmail.com
Mon Apr 4 12:33:54 PDT 2011


On Sun, Apr 3, 2011 at 3:23 AM, Gary Bernhardt <gary.bernhardt at gmail.com> wrote:
> 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.

Right, but does that include internally set names? Things like Text
boxes, Trees and Tables
don't have a title or label, and in those cases it's pretty useful to be able
to explicitly name them and use that name in the tests. Also, sometimes several
widgets have the same label.

>
>> 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.

Interesting. A quick look at AppleScript made it look like the Mac is
somewhat further on in this respect than other platforms from what I
could tell.

/Geoff



More information about the testing-in-python mailing list