Skip to content

Import hierarchies and naming conflicts

Lesson lab: Import hierarchies and naming conflictsch04-variables-keywords--import-hierarchies-and-conflicts.zip · 4 KB

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

Download ch04-variables-keywords--import-hierarchies-and-conflicts.zip

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

Terminal window
curl -fsSLO https://manykarim.github.io/robotframework-essentials-web/labs/ch04-variables-keywords--import-hierarchies-and-conflicts.zip && unzip -q ch04-variables-keywords--import-hierarchies-and-conflicts.zip && rm ch04-variables-keywords--import-hierarchies-and-conflicts.zip

Open the folder in VS Code with code rfe-ch04-variables-keywords--import-hierarchies-and-conflicts (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-ch04-variables-keywords--import-hierarchies-and-conflicts/
    • Directory.vscode/
      • extensions.json
    • Directorychecks/
      • imports.robot
    • Directoryresources/
      • backup.resource
      • common.resource
    • .gitignore
    • .python-version
    • LAB.md
    • pyproject.toml
    • README.md
    • requirements.txt
    • uv.lock

When two imports define a keyword with the same name, a bare call is ambiguous — Robot Framework refuses to guess and fails the test. You resolve it by qualifying the call: prefix the keyword with its source and a dot.

This chapter’s workspace imports two resources, common.resource and backup.resource, that both define Greet. The suite checks/imports.robot calls Greet unqualified, so it fails. Download this lesson’s lab, then qualify it.

Resolving a keyword name conflictstack diagramGreetunqualified calltwo imports define itAmbiguous — RF refuses to guessthe test failsqualify with Source.Keywordcommon.Greetnames the resource explicitlyresolves tocommon.resource's Greetthe test passes

Task 1 — Qualify the ambiguous keyword with its resource name

Section titled “Task 1 — Qualify the ambiguous keyword with its resource name”
Edit

Goal: in checks/imports.robot, change the ambiguous Greet call so it names the resource it should come from, and the test passes.

Here is the qualification syntax on a keyword you already know — Log from the built-in library. Source.Keyword picks the definition explicitly.

Worked example — adapt it, don’t copy it

*** Test Cases ***
Qualified Call Is Unambiguous
BuiltIn.Log named its library explicitly

Done when

checks/imports.robot qualifies the call as common.Greet, and the test passes.

Hint 1

Both resources define Greet. Prefix the call with the resource that owns the one you want — the file name without its .resource extension.

Hint 2

Change Greet world to common.Greet world to select the definition from common.resource.

Solution
*** Settings ***
Resource ../resources/common.resource
Resource ../resources/backup.resource
*** Test Cases ***
Greeting Works
common.Greet world
Run

Run it:

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

Done when

the test Greeting Works passes.

Check your understanding

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

  1. Two imported resources define a keyword with the same name. A bare call…

    Show the answer

    Answer: fails as ambiguous — you must qualify it — Robot Framework refuses an ambiguous call; qualify it with the source name, e.g. common.Greet.

  2. How do you qualify a keyword to resolve the conflict?

    Show the answer

    Answer: common.Greet — Prefix the keyword with its library or resource name and a dot: common.Greet.

Key terms

keyword qualificationconcept
Prefix a keyword with its source to resolve conflicts: common.Greet.

All terms in the glossary →