A simple test demonstrating how to do a context click in Geb.
Last active
August 29, 2015 13:56
-
-
Save spikeheap/8862048 to your computer and use it in GitHub Desktop.
Geb context clicks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply plugin: 'groovy' | |
| repositories{ | |
| mavenCentral() | |
| } | |
| dependencies{ | |
| compile 'org.codehaus.groovy:groovy-all:2.2.1' | |
| compile "org.gebish:geb-core:0.9.2", "org.gebish:geb-spock:0.9.2", "org.seleniumhq.selenium:selenium-firefox-driver:2.39.0", "org.seleniumhq.selenium:selenium-support:2.39.0" | |
| testCompile "org.spockframework:spock-core:0.7-groovy-2.0" | |
| } | |
| task runScript (dependsOn: 'classes', type: JavaExec) { | |
| main = 'contextClicker' | |
| classpath = sourceSets.main.runtimeClasspath | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // place in src/test/groovy/ | |
| import geb.Browser | |
| import geb.* | |
| import org.openqa.selenium.firefox.FirefoxDriver | |
| import geb.spock.GebSpec | |
| class contextClickerSpec extends GebSpec{ | |
| def "Context click opens menu"(){ | |
| setup: | |
| go "http://medialize.github.io/jQuery-contextMenu/demo.html" | |
| def contextBox = $(".context-menu-one") | |
| contextBox.text() == "right click me" | |
| when: "I context-click the div" | |
| interact{ contextClick(contextBox) } | |
| def editOption = $('li.context-menu-item:nth-child(1) > span:nth-child(1)') | |
| then: "It displays the edit option" | |
| editOption.displayed | |
| editOption.text() == "Edit" | |
| cleanup: | |
| quit() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment