使用页面对象模式,我想基于/ html / head / title元素的文本实现一些“ at”验证。
如何获得标题文字?
我知道Geb不支持XPath表达式。
@Tim_Yates是正确的,但是您专门询问了Page Object模型。
您可以设置成功加载页面的规则,如下所示:
class GoogleHomePage extends Page {
static url = "http://google.com/"
static at = { title == "Google" } // the bit you asked about
}
然后,您的实际测试:
Browser.drive {
to GoogleHomePage // goes to GoogleHomePage and verifies by calling at().
}
(如果您不想at()
检查,请使用via()
代替to()
。)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句