← Back to team overview

launchpad-dev team mailing list archive

Re: Heads up: Windmill test gotcha and solution

 

>> 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")')
> 

Hi Gavin

Thanks for the great tip. Clearly I'm not a Windmill expert :-)
As you may be aware, I only very recently packaged Windmill from trunk
and that's what we are now using with Launchpad, so the version we have
should include the functionality you mention. Next time someone is doing
something in this area, it would be well worth trying out the jquery
approach, and possibly doing drive-bys for places where it's appropriate
to do so. There's not that many of them.





References