Is there any way to add/print custom step/text in html reports

371 Views Asked by At

I am using athaydes spock-reports. I would like to insert some specific output texts in html reports. For that please refer below things which I have used so far. Below is my Spec file:

@Stepwise
class TC001_SMO_Scenario_Spec extends GebReportingSpec {
def "Step 1:Go to the login page of the WU"() {

        when: "User open the Login page"
        to LoginPage

        then: "Login page should get open"
        at LoginPage

        when: "User enters credentials"
        page.Login()

        then: "Home Page should get open"
        at HomePage
    }

    def "Step 2:User initiates transfer process"() {

        when: "Clicks on the Start New Transfer button"
        page.selectionOfItem()
        sleep(2000)

        then: "Reciept Number should be generated"
        at ManageConnections
        def recieptNumber =  tabConnections.text()
        reportInfo(recieptNumber )       
        reportInfo " Reciept Number is $recieptNumber "
    }
}

Now when the execution is done then below is the snapshot of report.

enter image description here

Now my requirement is that, there is some receipt number is getting generated on web page, I would like to have that to be printed in html report, after the Then block. (then: "Reciept Number should be generated"). Could you please guide me how this can be done with the help of specific geb/spock keywords or athaydes - spock-reports.

I referred the material from below site as well, however it's not working for me. https://github.com/renatoathaydes/spock-reports#how-to-use-it

Thanks for your help on this.

1

There are 1 best solutions below

0
On

Finally I got success and I believe I got the root cause as well.

If the spec file extends to Specification, then reportHeader and reportInfo keywords are working fine.

If you are using geb, by extending GebReportingSpec, then report() needs to be used to get customized steps to be added in geb spock html reports.

Thanks, Durgesh