Skip to content

Instantly share code, notes, and snippets.

@s992
Created June 26, 2014 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s992/a935c39fa2c600cee740 to your computer and use it in GitHub Desktop.
Save s992/a935c39fa2c600cee740 to your computer and use it in GitHub Desktop.
Learning geb!
import geb.Browser
import geb.Page
import geb.Module
class NavigationLink extends Module {
def linkText
static content = {
link { $("a", text: linkText) }
}
}
class NavigationBar extends Module {
static content = {
homeLink { module NavigationLink, linkText: "Home" }
archiveLink { module NavigationLink, linkText: "Archives" }
aboutLink { module NavigationLink, linkText: "About" }
}
}
class SwalshPage extends Page {
static content = {
navBar { module NavigationBar }
}
}
class HomePage extends SwalshPage {
static url = "http://swalsh.org"
static at = { title == "Sean Walsh" }
}
class ArchivesPage extends SwalshPage {
static url = "http://swalsh.org/archives"
static at = { title == "Blog Archive - Sean Walsh" }
}
class AboutPage extends SwalshPage {
static url = "http://swalsh.org/about"
static at = { title == "About - Sean Walsh" }
}
Browser.drive {
to HomePage
assert at( HomePage )
navBar.archiveLink.link.click()
assert at( ArchivesPage )
navBar.aboutLink.link.click()
assert at( AboutPage )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment