← Back to team overview

launchpad-dev team mailing list archive

Re: Heads up: Windmill test gotcha and solution

 

On 28 October 2010 01:54, Ian Booth <ian.booth@xxxxxxxxxxxxx> wrote:
> Hi
>
> I just wanted to share a problem that I got snagged on in case anyone
> else comes across the same thing. The issue affects Windmill tests and
> causes them to error with a client timeout exception. For me, it only
> started happening recently when I wrote a new test but around the same
> time also showed up on ec2 for other existing tests that I didn't write.
>
> When writing a Windmill test, you can wait for a page element like a
> button to appear so you know the page is loaded, before moving on to the
> next step in the test. This can be done like so:
>
> ADD_COMMENT_BUTTON = (
>    u'//input[@id="field.actions.save" and contains(@class, "button")]'
> client.waits.forElement(xpath=ADD_COMMENT_BUTTON)

I think contains(...) matches any substring, so the expression above
will match classes like "big-red-button" too. Probably not something
to worry about much, but it /might/ lead to difficult to diagnose
bugs.

I don't know if we have a new enough Windmill, but the documentation
(http://github.com/windmill/windmill/wiki/Controller-API) talks about
using jquery selectors (i.e. CSS selectors). If it is available its
use could help side-step that small issue:

    client.waits.forElement(
        jquery=u'("input.button#field.actions.save")')

Gavin.



Follow ups

References