Skip to content

Instantly share code, notes, and snippets.

@spikeheap
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save spikeheap/8845429 to your computer and use it in GitHub Desktop.

Select an option

Save spikeheap/8845429 to your computer and use it in GitHub Desktop.
Demo of double-click event handling in Geb
import geb.spock.GebReportingSpec
class failingSpec extends GebReportingSpec {
def "double clicking highlights the second div"(){
def elementIwant = $('div', text: 'Double-clickable div')
when: "I click an element"
elementIwant.click() // Works
then: "a div has the activated class applied to it"
$('div', text: 'single-clicked').hasClass("activated")
when: "I double-click an element"
elementIwant.dblClick() // Does nothing
then: "a different div has the activated class applied to it"
$('div', text: 'double-clicked').hasClass("activated") // assertion fails
}
}
import geb.spock.GebReportingSpec
class passingSpec extends GebReportingSpec {
def "double clicking highlights the second div"(){
def elementIwant = $('div', text: 'Double-clickable div')
when: "I click an element"
elementIwant.click() // Works
then: "a div has the activated class applied to it"
$('div', text: 'single-clicked').hasClass("activated")
when: "I double-click an element"
interact { doubleClick(elementIwant) }
then: "a different div has the activated class applied to it"
$('div', text: 'double-clicked').hasClass("activated") // assertion passes
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment