简体   繁体   中英

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

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.

在此处输入图片说明

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM