Skip to content

Running a process

Chapter lab: Processesch14-processes.zip · 7 KB

This chapter works in a prepared project. Download it before the first task; it unpacks into its own folder.

Download ch14-processes.zip

Or fetch and unpack it from a terminal in VS Code:

Terminal window
curl -fsSLO https://manykarim.github.io/robotframework-essentials-web/labs/ch14-processes.zip && unzip -q ch14-processes.zip && rm ch14-processes.zip

Open 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:

Terminal window
uv sync
Terminal window
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Keep the environment active in every terminal where you run lesson commands.

Terminal window
poetry install --no-root

Python 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”
Edit

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} Python

Done 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 Backpack
Run

Run:

Terminal window
uv run robot checks
Terminal window
robot checks
Terminal window
poetry run robot checks

Done 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.

  1. Which keyword runs an external command?

    Show the answer

    Answer: Run Process — The Process library's Run Process runs a command and returns a result object.

  2. The result of Run Process gives you…

    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.

All terms in the glossary →