【发布时间】:2015-09-21 20:51:26
【问题描述】:
我正在尝试重复使用我在另一个 Geb Spec 中编写的 Geb Spec 测试,因此我不需要重新编写代码。我总是需要不同页面中的产品编号,所以我想做类似以下的事情;
class BasePageGebSpec extends GebReportingSpec {
def firstProductOnBrowsePage(){
when:
to BrowsePage
then:
waitFor { BrowsePage }
productId { $("meta", 0, itemprop: "mpn").@content }
return productID // ???
}
}
在另一个 GebSpec 中,我希望使用上面的 firstProductOnBrowsePage,如下所示:
class ProductDetailsPageGebSpec extends BasePageGebSpec {
def "See first products details page"(){
when:
to ProductDetailsPage, productId: firstProductOnBrowsePage()
then:
waitFor { $("h2", class:"title").size() != 0 }
assert true
}
}
任何帮助将不胜感激,
谢谢!
【问题讨论】: