Created
November 4, 2012 00:33
-
-
Save tomoTaka01/4009577 to your computer and use it in GitHub Desktop.
my first Geb (for HelloSample)
This file contains 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
@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