# Save results in a .txt file

**URL:** <https://forum.robotframework.org/t/save-results-in-a-txt-file/5774>\
**Category:** Robot Framework\
**Created:** [1 June 2023 14:48 UTC](https://forum.robotframework.org/t/save-results-in-a-txt-file/5774 "2023-06-01T14:48:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CarlosPitero](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@CarlosPitero](https://forum.robotframework.org/u/CarlosPitero)\
**Post date:** [1 June 2023 14:48 UTC](https://forum.robotframework.org/t/save-results-in-a-txt-file/5774/1 "2023-06-01T14:48:19Z")

</div>

I have several testcases and I want to get the result of each one of them (PASS or FAIL) and save it in a .txt file. Is it possible to do it?

---

<div class="post-metadata">

**Author:** ![Many](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/many/32/658_2.png) [@Many](https://forum.robotframework.org/u/Many)\
**Post date:** [1 June 2023 15:47 UTC](https://forum.robotframework.org/t/save-results-in-a-txt-file/5774/2 "2023-06-01T15:47:10Z")

</div>

This is very similar to your description:  
[Robot Framework API | ROBOT FRAMEWORK](https://docs.robotframework.org/docs/extending_robot_framework/listeners_prerun_api/rf-api#access-and-modify-robot-framework-objects)

You can use the Robot Framework API to easily parse the Execution Result file and get the information you want.

---

<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:** [2 June 2023 01:24 UTC](https://forum.robotframework.org/t/save-results-in-a-txt-file/5774/3 "2023-06-02T01:24:38Z")

</div>

Hi Carlos,

There are many ways this could be achieved, including using the API as Many mentioned above, using Listeners (like I do in rfswarm)

But probably the easiest way is to simply create a keyword for logging the test result and call it with a [Test teardown](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#toc-entry-274).

Your keyword would combine the [Automatic variables](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#toc-entry-321) `${TEST STATUS}` and `${TEST MESSAGE}` with [Append To File](https://robotframework.org/robotframework/latest/libraries/OperatingSystem.html#Append%20To%20File) to write the text file.

You might find other Automatic variables useful too, e.g. `${SUITE NAME}` might be useful for the filename of the text file you want to create.  
You may also want to log the `${SUITE STATUS}` and `${SUITE MESSAGE}` to the same file from a [Suite teardown](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#toc-entry-291)

Dave.
