Robot Framework automatically taking screenshots at every step

I gave a keyword which basically simulates moving across a chart and hovering over each point in the chart. I am using mouse over to do this. what I have seen is that at each mouse over, robot is taking a screenshot which results in a large number of unnecessary screenshots. any ideas why ?

Validate LE Chart
[Arguments] ${Expected_points_Count}
${points_count}= Get Element Count ${chart_points}
Log ${points_count}
Should Be Equal As Numbers ${points_count} ${Expected_points_Count}
${points}= Get WebElements ${chart_points}
@{metric_list}= Create List CPU Memory Disk Session Count Total
FOR ${point} IN @{points}
Mouse Over ${point}
Mouse Over ${point}
${status}= Run Keyword And Return Status Wait Until Page Contains Element ${chart_tooltip} timeout=0
IF ${status} != ‘Fail’
${metrics}= Get WebElements ${chart_tooltip_points}
FOR ${metric} IN @{metrics}
${text}= Get Text ${metric}
END
END
END

Hi Naman,

Is Wait Until Page Contains Element failing a lot? that would trigger the screenshots, perhaps increase the timeout to something larger than 0, maybe 0.1?

Also you might want to look at Run-on-failure functionality which can be used to turn on / off the screenshots.

Dave.

Hi Damies
No there is no failure for that keyword. I have multiple tests in my suite and only for this I am seeing multiple screenshots.

Hi Naman,

The most common reason for triggering screenshots is a keyword that fails, but usually only 1 because then the test fails and stops, unless there is a keyword that prevents the test failing when a keyword fails, especially when that’s in a loop, that’s why I pointed at that line.

Nothing elese in the test you showd jumps out as the likely cause. The screenshows should be embeded in the log.html as images, so you’ll have to go through the log keyword by keyword and see where the screenshots are.

Maybe open log.html in a browser, open devtools and search the html for elements

hope that helps,

Dave.

hey damies
Issue was with the “wait until keyword only”. I missed it.
Thanks for your help

1 Like

How did you resolve it? Like I don’t want Robot Framework to take screenshot for wait until keyword.

Hi,

You would have to use Register Keyword To Run On Failure and set it to None.
Default behavior is Capture Page Screenshot on failure.

You may want probably to set it around the keyword you need to manage, if you want to keep screenshot on other failures.

Regards
Charlie

1 Like

Just another thought that I use, is to disable globally the screenshot on failure (especially if you’re using failed status/keyword to control your tests), and capture screenshot when test itself fail:

    IF    '${TEST_STATUS}' != 'PASS'
        Capture Page Screenshot    ${TEST_NAME}_Fail.png
    END

This can be set in Teardown to ensure a screen is made for analysis purposes.

Regards

Charlie