Capture screenshot on failure

822 views
Skip to first unread message

NagaRaju Dasam

unread,
Jul 9, 2015, 5:15:55 AM7/9/15
to geb-...@googlegroups.com
Hello Team,

i would like to capture screenshot on failure. Below is my script could you please suggest how to capture screenshot on failure.

I am using spock framework. I used report its capturing screenshot at the end of execution always i see login page...(after logout its navigating to login page). Is there any way i can capture screenshot when my script is failed

class VerifyFilterResultsSpec extends GebReportingSpec{

LoginService loginService = new LoginService()
LogoutService logoutService = new LogoutService()

def "Login as Merchant and verify the filter functionality in text box"() {

given:"Merchant user logs into application"
to LoginPage
loginService.login(EnvDetails.merchantUserName)

when:"Navigate to application"
to DashboardPage

then: "Verify View dropdown is available and check if the graphs are displayed"
at DashboardPage
assert complianceModule.ddViewSupplierPartnerGroupSelectedText.text()=='Suppliers'


cleanup: "Logout of application"
logoutService.logout()

}
}

--

Varun Menon

unread,
Jul 9, 2015, 5:21:08 AM7/9/15
to geb-...@googlegroups.com
Hi,

Geb have in-built screenshot reporter that you can use.

Look at the following links



- Varun

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/CAKfaP6Kh2FLyhXwkTsX0mNZMF2-%3DNSP4nG%2Br16PSSM5MafmdOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

NagaRaju Dasam

unread,
Jul 9, 2015, 5:28:18 AM7/9/15
to geb-...@googlegroups.com
Hi Varun,

It seems that feature is only for TestNG...i am using spock framework...

reportOnTestFailureOnly = true

its not working for spock..


For more options, visit https://groups.google.com/d/optout.

Colin Harrington

unread,
Jul 9, 2015, 10:22:55 AM7/9/15
to geb-...@googlegroups.com
With Geb + Spock you'll want to have your Spec extend GebReportingSpec.  That will automatically report before and after each test (after each failure too).  You can also manually call report() within your tests if you want multiple screenshots along the way. 

Hope that helps,

~ Colin Harrington

Colin Harrington
colin.ha...@gmail.com

Reply all
Reply to author
Forward
0 new messages