Display expected image when test fails in HTML test report --- not a feature

Asked by Asheru on 2019-04-15

Hello,

Right now in case of a test failure we show the screenshot in the HtmlTest report. Here is a snippet for this:

        runner = HagerHtmlTestRunner.HagerHtmlTestRunner(
                stream=output, title=HagercadConfig.HAGERCAD_HTML_REPORT_TITLE + " (Language: " + HagercadConfig.HAGERCAD_LANGUAGE_CODE + " ; OS: Win" + HagercadConfig.RUNNING_OS_VERSION + ")",
                description=HagercadConfig.HAGERCAD_HTML_REPORT_DESCRIPTION,
                dirTestScreenshots=HagercadConfig.HAGERCAD_TEST_REPORTS_FOLDER
        )

Is it possible to also display the image that is expected ( so the one that I'm using in a constant ) besides the screenshot taken in case of a failure? If it is , what's the approach?

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2019-04-15
Last reply:
2019-04-16
RaiMan (raimund-hocke) said : #1

apparently you are already using your own version of the HTMLTestRunner.

You have to track down in its code to the place, where the log entry is built and add another parameter for the used image.

I am sorry, but I have to leave you alone with that. Other priorities.

Asheru (asheru93) said : #2

Yeah, i;m using a custom HTMLTestRunner.

Thanks for the answer, so it is possible. At least I know that investing time in it will produce the desired result.

Asheru (asheru93) said : #3

One question though, how do I get the image that was not found? I mean from where do I get the current Findfailed image for example?

RaiMan (raimund-hocke) said : #4

Uuups, I thought, that you had already solved that (by some wrapper around the findop or the findFailedHandler faeture) .
In normal SikuliX, there is no feature like getLastUsedImage.

The FindFailed exception should have the information.

Asheru (asheru93) said : #5

I see. The thing is that I already have a customized framework already and a pretty straight (not flexbile) architecture for my scripts. I was thinking that maybe there is something like getLastUsedImage to be easier for me. I won't invest too much time in it if only the wrapper could do it.

Thanks :)

RaiMan (raimund-hocke) said : #6

solution has to be implemented by user

Asheru (asheru93) said : #7

Hello,

Coming back to this. So there is no possibility to link the image that was not found in the report besides modifying the FindFailed.class at the Java level? No other 'chances' on sikulix level?

So in case of "FindFailed: expected_image.png" a link for it inside the report.

Thanks.

RaiMan (raimund-hocke) said : #8

Modifying the FindFailed class does not help.

You have to add some Python code to the HTMLReport module.

I am sorry, but this currently is not one of my priorities.

Asheru (asheru93) said : #9

No problem.

I can't figure out exactly inside the HtmlReport module how can I get the image that is not found. From here I can do it but I can't figure out this.

RaiMan (raimund-hocke) said : #10

as mentioned:
add some support feature to your script code that stores the information in a way you can access it then in the HTMLReport modul.

the base is the FindFailed handler feature:

def ffhandler(event):
    print "in handler"
    print event.getImage().getFilename()
    # store this info somewhere
    event.setResponse(FindFailedResponse.ABORT) # finally abort

# this will register the handler with every newly defined region
setFindFailedHandler(ffhandler)

# if you need it for undotted find/wait/exist/click/... additionally use once
SCREEN.setFindFailedHandler(ffhandler)

If you have questions - come back

RaiMan (raimund-hocke) said : #11

--- UPDATE

    event.setResponse(FindFailedResponse.ABORT) # finally abort

in the handler is not needed, since ABORT is the default response if nothing else is set in the handler.

Asheru (asheru93) said : #12

Thanks for info.

I will give it a try. So basically I can add this anywhere but I have to call it in the file that handles the HTMLReport, right?

RaiMan (raimund-hocke) said : #13

The above mentioned code has to be somewhere in your script code where it is executed before the first Region object is defined.

In the handler store the filename/path of the failing image in some global variable, that is accessible in the HTMLReport module as well or in some text file.

Then in the FindFailed case at the appropriate place in the HTMLReport module evaluate and use this information.