Skip to content

Syntax rules

Lesson lab: Syntax rulesch02-first-suite--syntax-rules.zip · 3 KB

This lesson starts from a fresh lab — download it even if you already have the chapter lab.

Download ch02-first-suite--syntax-rules.zip

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

Terminal window
curl -fsSLO https://manykarim.github.io/robotframework-essentials-web/labs/ch02-first-suite--syntax-rules.zip && unzip -q ch02-first-suite--syntax-rules.zip && rm ch02-first-suite--syntax-rules.zip

Open the folder in VS Code with code rfe-ch02-first-suite--syntax-rules (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-ch02-first-suite--syntax-rules/
    • Directory.vscode/
      • extensions.json
    • Directorychecks/
      • first_suite.robot
    • .gitignore
    • .python-version
    • LAB.md
    • pyproject.toml
    • README.md
    • requirements.txt
    • uv.lock

Robot Framework’s syntax has a few rules that trip up newcomers, and all of them are about spacing and lines:

  • Separation — two or more spaces (or a tab) separate cells. A single space is part of the text.
  • Continuation — ... at the start of a line continues the previous line.
  • Comments — # starts a comment to end of line.
  • Escaping — \ escapes a special character; ${SPACE} is a deliberate single space.

This chapter’s workspace has a broken suite at checks/first_suite.robot: its cells are separated by a single space, so Robot Framework reads each line as one long keyword name and cannot find it. Download this lesson’s lab, then repair it.

Task 1 — Fix the cell separation in the broken suite

Section titled “Task 1 — Fix the cell separation in the broken suite”
Edit

Open checks/first_suite.robot. Each line uses single spaces. Widen the gap between every keyword and its arguments to two or more spaces:

*** Test Cases ***
Greeting Reads Clean
Log Robot Framework is running
Should Be Equal apples apples

Done when

the suite now calls the Log and Should Be Equal keywords.

Run

Run it:

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

Done when

the test Greeting Reads Clean passes.

Check your understanding

Quick recall. Your first answer stays in this browser; the quiz never blocks your progress.

  1. How does Robot Framework separate a keyword from its arguments?

    Show the answer

    Answer: Two or more spaces (or a tab) — Cells are separated by two or more spaces. A single space is part of the text, so Log Hello is read as one keyword name.

  2. How do you continue a long value onto the next line?

    Show the answer

    Answer: ... at the start of the line — The continuation marker ... begins a line that continues the previous one.

Key terms

cell separationconcept
Two or more spaces (or a tab) separate cells; a single space is literal text.
... (continuation)concept
Continues the previous line's value onto a new line.

All terms in the glossary →