Skip to content

Instantly share code, notes, and snippets.

@tomoTaka01
Created November 4, 2012 00:33
Show Gist options
  • Save tomoTaka01/4009577 to your computer and use it in GitHub Desktop.
Save tomoTaka01/4009577 to your computer and use it in GitHub Desktop.
my first Geb (for HelloSample)
@Grab("org.codehaus.geb:geb-core:latest.release")
@Grab("org.seleniumhq.selenium:selenium-firefox-driver:latest.release")
import geb.*
class HelloPage extends Page {
static url = 'http://localhost:8080/HelloSample/'
static at = {title == 'Hello'}
static content = {
nameInput {
$("input", name:"form1:name")
}
greetingButton (to:GreetingPage){
$("input", value:"greet")
}
}
}
class GreetingPage extends Page {
static at = {title == "Greeting"}
static content = {
h1Text {$('h1').text()}
}
}
Configuration conf = new Configuration()
//conf.setDriverConf('firefox')
//conf.setReportsDir(new File('Users/tomo'))
Browser.drive(){
to HelloPage
assert at(HelloPage)
// nameInput = "JGGUG" // ★2この記述では値が設定されない
nameInput.value("JGGUG") // ★2コメントで指摘していただいた方法で値設定
// report 'hello_page'
greetingButton.click()
assert at(GreetingPage)
// report 'Greeting_page'
assert h1Text == 'Hello JGGUG' // ★3テスト成功!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment