【发布时间】:2014-05-29 13:33:46
【问题描述】:
我最近一直在阅读 Geb 的书,并试图掌握它,因为它似乎是一个很棒的工具。我觉得我快到了,但仍有一些我似乎无法掌握的真正核心概念。
以网站为例:- http://www.escapistmagazine.com/videos/view/zero-punctuation
现在,如果我想测试列出的第一个视频是否链接到正确的页面,我首先想到的是执行以下操作
class ZeroPunctuationIndexPage extends Page {
static url = "http://www.escapistmagazine.com/videos/view/zero-punctuation"
static at = {title == "Zero Punctuation Video Gallery | The Escapist"}
static content = {
selectFirstVideo {$("a", 0, class: "filmstrip_video")}
firstVideoTitle {$("i", 0, class: "filmstrip_video")}
}
}
class ZeroPunctuationIndexSpec extends GebReportingSpec {
def "Click the latest video and play it"(){
given:
to ZeroPunctuationIndexPage
when:
selectFirstVideo.click()
then:
title.endsWith(firstVideoTitle)
}
}
基本上我想如果我选择包含视频的第一个类 (filmstrip_video),然后选择其中的链接,然后我可以单击它,并将链接中的视频标题与新页面标题进行比较。
再看一遍我并不惊讶它没有工作,但我不知道该怎么办。
如果有人能给我一个快速的解决方案,我将不胜感激。我没有对逃避现实页面做任何特别的事情,我只是选择了一个有视频索引的地方来尝试编写测试。
谢谢!
【问题讨论】: