Last active
August 2, 2016 03:16
-
-
Save aya-eiya/11205559 to your computer and use it in GitHub Desktop.
Groovyのちょっとしたこと「Gebによるテストについて」 ref: http://qiita.com/aya_eiya/items/613d4080da9a2bb283d6
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
package jp.eiya.aya.geb.practice | |
@Grab('org.gebish:geb-core') | |
import geb.Page | |
class CorrectedGoogleTopPage extends Page{ | |
static url = 'https://www.bing.com' // fail | |
static at = { | |
title == 'Google' | |
searchBox.value() == '' | |
} | |
static content = { | |
searchBox { | |
$('input[type=text]') | |
} | |
} | |
} |
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
import jp.eiya.aya.geb.practice.CorrectedGoogleTopPage as GoogleTopPage |
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
JUnit 4 Runner, Tests: 1, Failures: 1, Time: 1115 | |
Test Failure: a search word can be input(jp.eiya.aya.geb.practice.ThirdTest) | |
Assertion failed: | |
title == 'Google' | |
| | | |
Bing false |
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
JUnit 4 Runner, Tests: 1, Failures: 1, Time: 1115 | |
Test Failure: a search word can be input(jp.eiya.aya.geb.practice.ThirdTest) | |
Assertion failed: | |
title == 'Google' | |
| | | |
Bing false |
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
@Grab('org.gebish:geb-core') // 注意:geb-core最新版はorg.codehaus.gebのグループではない | |
@Grab('org.seleniumhq.selenium:selenium-java') | |
import geb.Browser | |
Browser.drive { | |
go 'https://google.co.jp' | |
$('input[type=text]').value('groovy') | |
assert $('input[type=text]').value() == 'groovy' | |
} |
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
package jp.eiya.aya.geb.practice | |
@Grab('org.gebish:geb-core') | |
import geb.Page | |
class GoogleTopPage extends Page{ | |
static url = 'https://google.co.jp' | |
static content = { | |
searchBox { | |
$('input[type=text]') | |
} | |
} | |
} |
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
@Grab('org.gebish:geb-core') | |
@Grab('org.gebish:geb-spock') | |
@Grab('org.seleniumhq.selenium:selenium-java') | |
import org.openqa.selenium.firefox.FirefoxDriver | |
import geb.spock.GebSpec | |
class SecondTest extends GebSpec { | |
def driver = { new FirefoxDriver() } | |
def 'a search word can be input'(){ | |
setup: | |
go 'https://google.co.jp' | |
when: | |
$('input[type=text]').value(inputWord) | |
then: | |
$('input[type=text]').value() == expectWord | |
where: | |
inputWord | expectWord | |
'groovy' | 'groovy' | |
} | |
} |
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
@Grab('org.gebish:geb-core') | |
@Grab('org.gebish:geb-spock') | |
@Grab('org.seleniumhq.selenium:selenium-java') | |
import org.openqa.selenium.firefox.FirefoxDriver | |
import geb.spock.GebSpec | |
import jp.eiya.aya.geb.practice.GoogleTopPage | |
class ThirdTest extends GebSpec { | |
def driver = { new FirefoxDriver() } | |
def 'a search word can be input'(){ | |
setup: | |
to GoogleTopPage | |
when: | |
searchBox.value(inputWord) | |
then: | |
searchBox.value() == expectWord | |
where: | |
inputWord | expectWord | |
'groovy' | 'groovy' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment