# Robot Framework automatically taking screenshots at every step

**URL:** https://forum.robotframework.org/t/robot-framework-automatically-taking-screenshots-at-every-step/6799
**Category:** SeleniumLibrary
**Created:** [8 February 2024 04:59 UTC](https://forum.robotframework.org/t/robot-framework-automatically-taking-screenshots-at-every-step/6799 "2024-02-08T04:59:09Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![nman39](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@nman39](https://forum.robotframework.org/u/nman39)
#### Post date: [8 February 2024 04:59 UTC](https://forum.robotframework.org/t/robot-framework-automatically-taking-screenshots-at-every-step/6799/1 "2024-02-08T04:59:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)
#### Post date: [8 February 2024 05:47 UTC](https://forum.robotframework.org/t/robot-framework-automatically-taking-screenshots-at-every-step/6799/2 "2024-02-08T05:47:51Z")

</div>

Hi Naman,

> [@nman39](#):
>
> ${status}= Run Keyword And Return Status Wait Until Page Contains Element ${chart\_tooltip} timeout=0

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](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Run-on-failure%20functionality) which can be used to turn on / off the screenshots.

Dave.

---

<div class="post-metadata">

### Author: ![nman39](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@nman39](https://forum.robotframework.org/u/nman39)
#### Post date: [8 February 2024 05:56 UTC](https://forum.robotframework.org/t/robot-framework-automatically-taking-screenshots-at-every-step/6799/3 "2024-02-08T05:56:01Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)
#### Post date: [8 February 2024 06:43 UTC](https://forum.robotframework.org/t/robot-framework-automatically-taking-screenshots-at-every-step/6799/4 "2024-02-08T06:43:40Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![nman39](https://avatars.discourse-cdn.com/v4/letter/n/90ced4/32.png) [@nman39](https://forum.robotframework.org/u/nman39)
#### Post date: [8 February 2024 08:03 UTC](https://forum.robotframework.org/t/robot-framework-automatically-taking-screenshots-at-every-step/6799/5 "2024-02-08T08:03:41Z")

</div>

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

---

<div class="post-metadata">

### Author: ![sachinpatil280](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/sachinpatil280/32/3160_2.png) [@sachinpatil280](https://forum.robotframework.org/u/sachinpatil280)
#### Post date: [1 May 2024 21:31 UTC](https://forum.robotframework.org/t/robot-framework-automatically-taking-screenshots-at-every-step/6799/6 "2024-05-01T21:31:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![CharlieScene](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/charliescene/32/3484_2.png) [@CharlieScene](https://forum.robotframework.org/u/CharlieScene)
#### Post date: [1 May 2024 21:59 UTC](https://forum.robotframework.org/t/robot-framework-automatically-taking-screenshots-at-every-step/6799/7 "2024-05-01T21:59:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![CharlieScene](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/charliescene/32/3484_2.png) [@CharlieScene](https://forum.robotframework.org/u/CharlieScene)
#### Post date: [2 May 2024 07:31 UTC](https://forum.robotframework.org/t/robot-framework-automatically-taking-screenshots-at-every-step/6799/8 "2024-05-02T07:31:55Z")

</div>

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
