automated testing of applications written with wxPython

Hello

I have a fairly large proprietary application written in python 2.6
with wxPython 2.9. Runs on windows.
As new features are added, manual testing is expensive and bugs tend
to creep out all the time.
I am looking for advice on which automated testing technologies/
frameworks are easier to be integrated and used with wxPython.

Thanks

Fabio

You may be able to grow your own using the new wx.UIActionSimulator class.

···

On 11/5/11 10:57 AM, fabio67 wrote:

Hello

I have a fairly large proprietary application written in python 2.6
with wxPython 2.9. Runs on windows.
As new features are added, manual testing is expensive and bugs tend
to creep out all the time.
I am looking for advice on which automated testing technologies/
frameworks are easier to be integrated and used with wxPython.

--
Robin Dunn
Software Craftsman

I'm interested in this topic also.

This has been recommended, but I haven't yet used it:
   http://sikuli.org/

Michael

···

On 11/5/2011 12:57 PM, fabio67 wrote:

I have a fairly large proprietary application written in python 2.6
with wxPython 2.9. Runs on windows.
As new features are added, manual testing is expensive and bugs tend
to creep out all the time.
I am looking for advice on which automated testing technologies/
frameworks are easier to be integrated and used with wxPython.

I’m curious: Has anyone on this list tried it?

I’ve avoided automated testing, but this looks tempting. I saw it a couple of years ago but hadn’t thought to apply it to testing wxPython apps. For those checking it out, see the video on their site.

Che

···

On Sat, Nov 5, 2011 at 3:08 PM, Michael Hipp michael@redmule.com wrote:

On 11/5/2011 12:57 PM, fabio67 wrote:

I have a fairly large proprietary application written in python 2.6

with wxPython 2.9. Runs on windows.

As new features are added, manual testing is expensive and bugs tend

to creep out all the time.

I am looking for advice on which automated testing technologies/

frameworks are easier to be integrated and used with wxPython.

I’m interested in this topic also.

This has been recommended, but I haven’t yet used it:

http://sikuli.org/

Hi Che,

I have a fairly large proprietary application written in python 2.6

with wxPython 2.9. Runs on windows.

As new features are added, manual testing is expensive and bugs tend

to creep out all the time.

I am looking for advice on which automated testing technologies/

frameworks are easier to be integrated and used with wxPython.

I’m interested in this topic also.

This has been recommended, but I haven’t yet used it:

http://sikuli.org/

I’m curious: Has anyone on this list tried it?

I’ve avoided automated testing, but this looks tempting. I saw it a couple of years ago but hadn’t thought to apply it to testing wxPython apps. For those checking it out, see the video on their site.

Image-based automated testing is certainly better than nothing (and does allow you write tests for almost anything on your machine), but in my experience it tends to be very fragile. Since the tool is always using screenshots to determine what to click on and where, doing something like upgrading your test machine from Leopard to Snow Leopard or Lion can break many or all of your tests because of OS-level UI changes that cause Sikuli not to “find” the UI elements it is looking for anymore. I’d use it only when there’s nothing better available.

For wx, though, wx.UIActionSimulator in 2.9.2 can create tests that can run properly cross-platform, and it does so by using wx APIs to query where the UI elements are, then programmatically moving the mouse to them and clicking on them, or doing drags, etc. Since these kinds of tests don’t need to have exact pixel coordinates for your UI elements, they will work on different machines and platforms. It might be counter-intuitive to think of writing a script to visually test a GUI, but it seems to work pretty well. :slight_smile: It probably wouldn’t even be hard to write some helper tool that records UI interactions and then plays them back as an automated test, if Robin hasn’t once again borrowed Guido’s time machine and done something like it already. :wink:

Regards,

Kevin

···

On Nov 6, 2011, at 4:05 PM, C M wrote:

On Sat, Nov 5, 2011 at 3:08 PM, Michael Hipp michael@redmule.com wrote:

On 11/5/2011 12:57 PM, fabio67 wrote:

Che

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

There is the beginnings of something like that in the demo. It only handles key events and only for one widget, but it could be a good starting point.

···

On 11/6/11 5:56 PM, Kevin Ollivier wrote:

For wx, though, wx.UIActionSimulator in 2.9.2 can create tests that can
run properly cross-platform, and it does so by using wx APIs to query
where the UI elements are, then programmatically moving the mouse to
them and clicking on them, or doing drags, etc. Since these kinds of
tests don't need to have exact pixel coordinates for your UI elements,
they will work on different machines and platforms. It might be
counter-intuitive to think of writing a script to visually test a GUI,
but it seems to work pretty well. :slight_smile: It probably wouldn't even be hard
to write some helper tool that records UI interactions and then plays
them back as an automated test, if Robin hasn't once again borrowed
Guido's time machine and done something like it already. :wink:

--
Robin Dunn
Software Craftsman

Thanks to everybody.

I am trying with this strategy: the test controller runs in the same
process space as the application under test, as a separate thread.
The test controller sends messages to the application using
wx.PostEvent, simulating the GUI events.
This way I am able to open and close the application, and to activate
functions from the menu.
It works and it is reasonably easy to automate.
The advantage of being in the same address space is that you can
easily poke the application status variables to make the test PASS/
FAIL.
This is something you can't do if you run test automation from a
different process.

One of the menus opens a wx.FileDialog. I would like to inject the
keys into the dialog and continue the test, but I do not know how to
find the handle to the dialog.
Of course I could change the application to save the handle somewhere
as a property that I can read from the test controller.
But maybe there's just a easier solution that I do not know. I
remember time ago visual basic had a function FindWindow(classname,
caption).
I have not found anything like that in wxPython.

Fabio

···

On 7 Nov, 05:22, Robin Dunn <ro...@alldunn.com> wrote:

On 11/6/11 5:56 PM, Kevin Ollivier wrote:

> For wx, though, wx.UIActionSimulator in 2.9.2 can create tests that can
> run properly cross-platform, and it does so by using wx APIs to query
> where the UI elements are, then programmatically moving the mouse to
> them and clicking on them, or doing drags, etc. Since these kinds of
> tests don't need to have exact pixel coordinates for your UI elements,
> they will work on different machines and platforms. It might be
> counter-intuitive to think of writing a script to visually test a GUI,
> but it seems to work pretty well. :slight_smile: It probably wouldn't even be hard
> to write some helper tool that records UI interactions and then plays
> them back as an automated test, if Robin hasn't once again borrowed
> Guido's time machine and done something like it already. :wink:

There is the beginnings of something like that in the demo. It only
handles key events and only for one widget, but it could be a good
starting point.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

You can use wx.FindWindowByLabel(window_lable)

Gadget/Steve

···

On 10/11/2011 10:33 AM, fabio67 wrote:

Thanks to everybody.

I am trying with this strategy: the test controller runs in the same
process space as the application under test, as a separate thread.
The test controller sends messages to the application using
wx.PostEvent, simulating the GUI events.
This way I am able to open and close the application, and to activate
functions from the menu.
It works and it is reasonably easy to automate.
The advantage of being in the same address space is that you can
easily poke the application status variables to make the test PASS/
FAIL.
This is something you can't do if you run test automation from a
different process.

One of the menus opens a wx.FileDialog. I would like to inject the
keys into the dialog and continue the test, but I do not know how to
find the handle to the dialog.
Of course I could change the application to save the handle somewhere
as a property that I can read from the test controller.
But maybe there's just a easier solution that I do not know. I
remember time ago visual basic had a function FindWindow(classname,
caption).
I have not found anything like that in wxPython.

Fabio

In general I have found most wx functions cannot be used in a separate
thread, including wx.FindWindow*.
I have found pywinauto, easy to use and effective.

···

On 10 Nov, 14:53, Gadget/Steve <GadgetSt...@live.co.uk> wrote:

On 10/11/2011 10:33 AM, fabio67 wrote:

> Thanks to everybody.

> I am trying with this strategy: the test controller runs in the same
> process space as the application under test, as a separate thread.
> The test controller sends messages to the application using
> wx.PostEvent, simulating theGUIevents.
> This way I am able to open and close the application, and to activate
> functions from the menu.
> It works and it is reasonably easy to automate.
> The advantage of being in the same address space is that you can
> easily poke the application status variables to make the test PASS/
> FAIL.
> This is something you can't do if you run test automation from a
> different process.

> One of the menus opens a wx.FileDialog. I would like to inject the
> keys into the dialog and continue the test, but I do not know how to
> find the handle to the dialog.
> Of course I could change the application to save the handle somewhere
> as a property that I can read from the test controller.
> But maybe there's just a easier solution that I do not know. I
> remember time ago visual basic had a function FindWindow(classname,
> caption).
> I have not found anything like that in wxPython.

>Fabio

You can use wx.FindWindowByLabel(window_lable)

Gadget/Steve

I’m working on Linux (Ubuntu 12.04). I have a full screen application running and want to show a floating frame above it. The frame shows just fine, but it also shows the desktop taskbar at the bottom of the screen, which I don’t want. (Xubuntu desktop).

I tried adding STAY_ON_TOP to both the main app frame and the floating frame with no effect. A standard dialog does not do this, only the MessageFrame class I wrote does this. It happens if I pass the main app frame as parent or None as parent, modal or not modal.

The relevant code:

def init(self, parent=None, title="", msg="", size=(250,50),
pad=(20,40), layout=None, modal=True):
“”"
Constructor.
“”"

    bcolor = layout["colors"]["app_bcolor"]
    fcolor = layout["colors"]["text_fcolor"]
    font = layout["fonts"]["font14"]

    #  Get position info
    if (parent != None):
        self.parent = parent.GetTopLevelParent()
        xy = parent.GetTopLevelParent().GetScreenPositionTuple()
        sxy = parent.GetTopLevelParent().GetSizeTuple()
        xy = (xy[0]+sxy[0]/2-size[0]/2, xy[1]+sxy[1]/2-size[1]/2)
        if (xy[0] < 0):
            xy = (0, xy[1])
        if (xy[1] < 0):
            xy = (xy[0], 0)

    #  Setup the frame
    if (parent != None):
        self.frame = wx.Frame(parent, -1, title, size=size, pos=xy, style=wx.RAISED_BORDER)
    else:
        self.frame = wx.Frame(parent, -1, title, size=size, style=wx.RAISED_BORDER)

    if (modal):
        self.frame.MakeModal(True)

    #  Put a panel on the frame
    self.panel = wx.Panel(self.frame, -1)
    self.panel.SetBackgroundColour(bcolor)

    #  Put the message on the panel
    box = wx.BoxSizer(wx.HORIZONTAL)
    self.msg = wx.StaticText(self.panel, -1, msg, style=wx.ALIGN_CENTER)
    self.msg.SetFont(font)
    self.msg.SetForegroundColour(fcolor)
    box.Add(pad, 0)
    box.Add(self.msg, 0, wx.ALIGN_CENTER)
    box.Add(pad, 0)
    self.panel.SetSizer(box)
    box.Fit(self.frame)

    #  Show the frame
    self.frame.Show()
    self.frame.Refresh()
    wx.GetApp().ProcessPendingEvents()

Does anyone know how to get this to always float over the without showing any of the underlying desktop?

Thanks!

Ron

I'm working on Linux (Ubuntu 12.04). I have a full screen application
running and want to show a floating frame above it. The frame shows just
fine, but it also shows the desktop taskbar at the bottom of the screen,
which I don't want. (Xubuntu desktop).

I tried adding STAY_ON_TOP to both the main app frame and the floating
frame with no effect. A standard dialog does not do this, only the
MessageFrame class I wrote does this. It happens if I pass the main app
frame as parent or None as parent, modal or not modal.

The relevant code:

http://wiki.wxpython.org/MakingSampleApps

Does anyone know how to get this to always float over the without
showing any of the underlying desktop?

It may be a feature of the desktop environment that we can't do anything about. You may find somebody on wx-users that knows more about this however.

···

On 5/17/12 6:28 AM, Ron Kneusel wrote:

--
Robin Dunn
Software Craftsman