Combining file and process checks
Chapter lab: Processes
This lesson continues in the same lab as the lesson before it. If you don’t have it yet, download it here.
Or fetch and unpack it from a terminal in VS Code:
curl -fsSLO https://manykarim.github.io/robotframework-essentials-web/labs/ch14-processes.zip && unzip -q ch14-processes.zip && rm ch14-processes.zipInvoke-WebRequest https://manykarim.github.io/robotframework-essentials-web/labs/ch14-processes.zip -OutFile ch14-processes.zip; Expand-Archive ch14-processes.zip -DestinationPath .; Remove-Item ch14-processes.zipOpen the folder in VS Code with code rfe-ch14-processes (or File → Open Folder…) and accept the recommended RobotCode and Python extensions. Then set it up:
uv syncpython3 -m venv .venvsource .venv/bin/activatepip install -r requirements.txtpython -m venv .venv.venv\Scripts\Activate.ps1pip install -r requirements.txtKeep the environment active in every terminal where you run lesson commands.
poetry install --no-rootPython 3.13 or newer is required; uv installs it when it is missing.
Open in browserNo setup? Try the lab right here: its files, an editor and a terminal, running in your browser.
What's inside
Directoryrfe-ch14-processes/
Directory.vscode/
- extensions.json
Directorychecks/
- smoke.robot
Directorysample_data/
- app.log
- catalog.xml
- orders.csv
- results.xml
- settings.cfg
Directorytools/
- inventory.py
- .gitignore
- .python-version
- LAB.md
- pyproject.toml
- README.md
- requirements.txt
- uv.lock
Real checks combine libraries. Run a process, capture its output to a file
with stdout=<path>, then read that file back with OperatingSystem and assert
on it. That is the pattern for verifying what a tool produced.
Task 1 — Capture process output to a file and verify it
Section titled “Task 1 — Capture process output to a file and verify it”Goal: create checks/combine.robot that runs tools/inventory.py list,
captures its stdout to a file under ${OUTPUT_DIR}, then reads that file back
and asserts a product name is in it.
Here is the same capture-then-verify flow over a different command. Adapt it.
Worked example — adapt it, don’t copy it
*** Settings ***Library ProcessLibrary OperatingSystem
*** Test Cases ***Save Version To A File ${result}= Run Process python3 --version stdout=${OUTPUT_DIR}/version.txt Should Be Equal As Integers ${result.rc} 0 File Should Exist ${OUTPUT_DIR}/version.txt ${text}= Get File ${OUTPUT_DIR}/version.txt Should Contain ${text} PythonDone when
the suite defines Capture Inventory To A File.
Hint 1
Add stdout=${OUTPUT_DIR}/inventory.txt as a trailing cell on the
Run Process python3 tools/inventory.py list call to capture its output.
Hint 2
After the run, File Should Exist ${OUTPUT_DIR}/inventory.txt, then
Get File it and Should Contain ${captured} Travel Mug.
Solution
*** Settings ***Library ProcessLibrary OperatingSystem
*** Test Cases ***Capture Inventory To A File ${result}= Run Process python3 tools/inventory.py list stdout=${OUTPUT_DIR}/inventory.txt Should Be Equal As Integers ${result.rc} 0 File Should Exist ${OUTPUT_DIR}/inventory.txt ${captured}= Get File ${OUTPUT_DIR}/inventory.txt Should Contain ${captured} Travel MugTask 2 — Run it green
Section titled “Task 2 — Run it green”Run:
uv run robot checksrobot checkspoetry run robot checksDone when
the CLI output is captured to a file, then read and verified.
Check your understanding
Quick recall. Your first answer stays in this browser; the quiz never blocks your progress.
How do you send a process's stdout to a file?
Run Processtakes astdout=<path>argument that writes the output to a file.Show the answer
Answer:
Run Process … stdout=path—Run Processtakes astdout=<path>argument that writes the output to a file.Combining Process and OperatingSystem lets you…
Run a process, capture its output to a file, then read and assert on that file.
Show the answer
Answer: run a tool and then assert on the file it produced — Run a process, capture its output to a file, then read and assert on that file.
Key terms
- stdout=<path>concept
- Run Process argument that redirects output to a file.