Created
March 29, 2012 04:09
-
-
Save zachlendon/2233214 to your computer and use it in GitHub Desktop.
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
| Runnning one of: | |
| grails -Dgeb.env=local-iphone test-app functional: | |
| grails -Dgeb.env=local-ipad test-app functional: | |
| grails test-app functional: | |
| at the command line, with the following files: | |
| GebConfig.groovy | |
| /* | |
| This is the Geb configuration file. | |
| See: http://www.gebish.org/manual/current/configuration.html | |
| */ | |
| import org.openqa.selenium.firefox.FirefoxDriver | |
| import org.openqa.selenium.remote.DesiredCapabilities | |
| import org.openqa.selenium.remote.RemoteWebDriver | |
| driver = { | |
| def driver = new FirefoxDriver(DesiredCapabilities.iphone()) | |
| driver.javascriptEnabled = true | |
| driver | |
| } | |
| environments { | |
| // when system property 'geb.env' is set to 'local-iphone' use a local iphone device driver | |
| 'local-iphone' { | |
| baseUrl = "http://10.0.1.8:5432" //address of your local app instance, on your network (not localhost) | |
| cachedDriver = new RemoteWebDriver(new URL(baseUrl), DesiredCapabilities.iphone()) | |
| } | |
| 'local-ipad' { | |
| baseUrl = "http://10.0.1.8:5432" //address of your local app instance, on your network (not localhost) | |
| cachedDriver = new RemoteWebDriver(new URL(baseUrl), DesiredCapabilities.ipad()) | |
| } | |
| 'test' { | |
| cachedDriver = new FirefoxDriver(DesiredCapabilities.firefox()) | |
| } | |
| } | |
| class MobileSpeck extends GebSpec { | |
| @Shared def cachedDriver | |
| @Shared def baseUrl | |
| def setupSpec() { | |
| def grailsApplication = ServletContextHolder.getServletContext().getAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT).getBean("grailsApplication") //not injectable | |
| cachedDriver = grailsApplication.config.cachedDriver | |
| browser.driver = cachedDriver | |
| } | |
| def setup() { | |
| // assign this as the default driver on the browser for each test | |
| browser.driver = cachedDriver | |
| setupSpec() | |
| } | |
| def cleanupSpec() { | |
| // after running the spec, kill the driver | |
| browser.close() | |
| cachedDriver.quit() | |
| } | |
| } | |
| class HomePageSpec extends MobilSpeck { | |
| def "home page smoke test"() { | |
| when: | |
| to HomePage | |
| then: | |
| at HomePage | |
| } | |
| } | |
| class HomePage extends Page { | |
| static url = baseUrl + "/" | |
| static content = { | |
| heading1(required: false) { $(".heading1") | |
| } | |
| static at = { | |
| heading1.text() ==~ /Hello World!/ | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment