Skip to content

Instantly share code, notes, and snippets.

@keesun
Last active August 29, 2015 14:01
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 keesun/312579c18d73354e7173 to your computer and use it in GitHub Desktop.
Save keesun/312579c18d73354e7173 to your computer and use it in GitHub Desktop.
Geb test with Spock
package pages
import geb.Page
/**
* @author Keeun Baik
*/
class LoginPage extends Page {
static url = "/users/loginform"
static at = { title == "로그인" }
static content = {
idInput { $("#loginId") }
passwordInput { $("#password") }
loginBtn { $(".login-form-wrap button") }
}
def loginAsTester() {
idInput = "yobitest"
passwordInput = "yobitest"
loginBtn.click()
}
}
package pages
import geb.Page
/**
* @author Keeun Baik
*/
class NewIssuePage extends Page {
static url = "/yobitest/hehe/issueform"
static at = { title == "새 이슈 (hehe)" }
static content = {
bodyTextarea { $("#body") }
}
}
import geb.spock.GebSpec
import org.openqa.selenium.Keys
import pages.HomePage
import pages.LoginPage
import pages.NewIssuePage
/**
* @author Keeun Baik
*/
class NewIssueSpec extends GebSpec {
def "이슈 본문 입력 할 때 '@채'를 입력해서 doortts 멘션하기"() {
when: "로그인 페이지로 이동해서 테스트 계정으로 로그인한다."
to LoginPage
loginAsTester()
then: "로그인을 마치고 홈페이지로 이동했는지 확인한다."
assert at(HomePage)
when: "새 이슈 작성 폼으로 이동한다."
to NewIssuePage
then: "새 이슈 작성 폼으로 이동했는지 확인한다."
assert at(NewIssuePage)
when: "'@'을 입력한다."
bodyTextarea << "@"
then: "맨션 목록에 2개의 항목이 들어있는지 확인한다. 첫번째 항목은 '채수원'이고 두번쨰 항목은 '백기선'인지 확인한다."
assert $("ul.atwho-view-ul li").size() == 2
assert $("ul.atwho-view-ul li")[0].text().contains("채수원")
assert $("ul.atwho-view-ul li")[1].text().contains("백기선")
when: "'@'에 이어서 '채'를 입력한다."
bodyTextarea << "채"
then: "이번에는 멘션 목록에 항목이 1개여야 하며, '채수원'이어야 한다."
assert $("ul.atwho-view-ul li").size() == 1
assert $("ul.atwho-view-ul li")[0].text().contains("채수원")
when: "리턴을 입력한다."
bodyTextarea << Keys.chord(Keys.RETURN)
then: "이슈 본문에 '@doortts'가 자동완성 되었는지 확인한다."
assert bodyTextarea.value().contains("@doortts")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment