Testing double-click events using Geb06 Feb 2014
, 1 minute read
Testing basic interaction with Geb is easy, but the ‘intuitive’ way of doing double-clicks fails silently and without any real indication as to why. Fortunately there’s a simple solution!
My first approach was to use
dblClick() in place of
click(). The result was a test which compiled and ran, but failed to generate the double click event:
It turns out that double-clicking is a “complex interaction”, and because it isn’t used that much on webpages it’s not part of the core functionality of NonEmptyNavigator.
Fortunately building complex interactions is trivial in Geb, so my updated Spock test only needs one line replacing:
Great, on to the next test!
Here’s another example, this time using interactions to do a context-click (right-click to you an me!):
If you want to run the test, the following gradle script will sort you out:
Was this post useful? Why not help others find it by sharing on twitter. While you're there, get in touch and let me know what you think!