标签: geb

如何在geb中的模块中截取屏幕截图

嗨,我们在 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)

spock geb

0
推荐指数
1
解决办法
1942
查看次数

在同一测试中使用 Geb & Spock 重启浏览器

我希望能够使用 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)

selenium spock geb

0
推荐指数
1
解决办法
1414
查看次数

使用Spock数据表来测试Geb页面对象

完全披露:我对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元素没有被正确替换?

groovy spock geb

0
推荐指数
1
解决办法
424
查看次数

如何在groovy中调用另一个类的方法?

对于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+Classeshttp://groovy.codehaus.org/Groovy+Beans但是没办法.任何建议或示例都会非常有用.

groovy spock geb

-2
推荐指数
1
解决办法
7700
查看次数

标签 统计

geb ×4

spock ×4

groovy ×2

selenium ×1