Running a process
Chapter lab: Processes
This chapter works in a prepared project. Download it before the first task; it unpacks into its own folder.
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
The Process standard library runs external commands. Run Process returns
a result object with .rc (exit code), .stdout, and .stderr. This part’s
workspace ships a small CLI, tools/inventory.py, to drive.
Task 1 — Run the inventory CLI and read its output
Section titled “Task 1 — Run the inventory CLI and read its output”Goal: create checks/process.robot that imports Process, runs
tools/inventory.py list, asserts a clean exit, and checks a product name in
its output.
Here is the same pattern over a different command. Adapt it to the CLI.
Worked example — adapt it, don’t copy it
*** Settings ***Library Process
*** Test Cases ***Python Reports Its Version ${result}= Run Process python3 --version Should Be Equal As Integers ${result.rc} 0 Should Contain ${result.stdout} PythonDone when
the suite imports Process and uses Run Process.
Hint 1
Run the CLI by passing its path and subcommand as separate cells:
Run Process python3 tools/inventory.py list.
Hint 2
A clean run exits 0 — assert Should Be Equal As Integers ${result.rc} 0
— and list prints product names, so Should Contain ${result.stdout} Trail Backpack.
Solution
*** Settings ***Library Process
*** Test Cases ***List Products With The CLI ${result}= Run Process python3 tools/inventory.py list Should Be Equal As Integers ${result.rc} 0 Should Contain ${result.stdout} Trail BackpackTask 2 — Run it green
Section titled “Task 2 — Run it green”Run:
uv run robot checksrobot checkspoetry run robot checksDone when
the CLI runs, exits 0, and its output lists the products.
Check your understanding
Quick recall. Your first answer stays in this browser; the quiz never blocks your progress.
Which keyword runs an external command?
The Process library's
Run Processruns a command and returns a result object.Show the answer
Answer:
Run Process— The Process library'sRun Processruns a command and returns a result object.The result of
Run Processgives you…${result.rc},${result.stdout}, and${result.stderr}are all available.Show the answer
Answer:
.rc,.stdout, and.stderr—${result.rc},${result.stdout}, and${result.stderr}are all available.
Key terms
- Processconcept
- Standard library for running external processes.
- Run Processkeyword
- Run a command; the result has
.rc,.stdout,.stderr.