嗨,我们在 Spock 框架上运行 Geb 测试。我正在尝试使用报告“屏幕截图”在模块中截取屏幕截图。它不像在规范上那样识别报告功能。我应该如何在模块中截取屏幕截图。
这是一个模块中的示例代码。
try{
$(By.xpath("//button[@ng-click=\"ok()\"]")).click()
}
catch (Throwable t){
failures.add("\n Could not click on the Ok button after the Ticket created successfully message appeared")
report "Failure"
}
Run Code Online (Sandbox Code Playgroud) 我希望能够使用 Geb 和 Spock 框架重新启动我的浏览器会话中期测试。我不知道如何关闭浏览器并在测试完成等之后更新,但是当我在测试期间关闭并尝试重新使用浏览器对象时,我收到了 selenium 抛出的会话错误。以下是我正在尝试执行的基本大纲。NB 从不允许我导航到新的 StoreHome,如果我尝试只使用浏览器,我会抛出错误。
@Category(High.class)
def "TC1: Verify Browser Restart"() {
when: "On my StoreFront HP wait until title displayed"
to StoreHomePage
waitFor { homepagetitle.displayed }
then: "Update your site picker"
mySitePicker.click()
waitFor { myNewHomePageTitle.displayed }
when: "Close the browser and insure on restart new page is loaded"
browser.close()
browser.quit()
def nb = new Browser()
nb.to(NewStoreHomePage)
then: "Validate on New HP"
asset myNewHomePageTitle.displayed
}
Run Code Online (Sandbox Code Playgroud) 完全披露:我对Geb和Spock都很陌生.
作为我正在研究的测试套件的一部分,我们必须测试在几个页面元素上运行相同的测试.我希望能够使用Spock数据表来抽象这种行为.但是,当我这样做时,Geb抱怨它无法识别页面属性.
这是我正在谈论的一个简单的例子:
when:
textBox = value
submit()
then:"value is updated"
at SuccessPage
textBox == value
where:
textBox | value
box1 | val1
box2 | val2
box3 | val3
Run Code Online (Sandbox Code Playgroud)
在此实例中,盒1-3的定义内容一个的对象页面.
这些测试在我独立完成时起作用,但在我使用数据表时则不行.为什么Geb元素没有被正确替换?
对于Instance,我有一个这样的类:
class firstOne{
....
def A (){
}
}
class secondOne{
// I need to call and use method A from class firstOne
// even I get error if I try to follow Java like calls
// firstOne method = new firstOne();
// method.A()
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试过http://groovy.codehaus.org/Scripts+and+Classes和http://groovy.codehaus.org/Groovy+Beans但是没办法.任何建议或示例都会非常有用.