Import hierarchies and naming conflicts
Lesson lab: Import hierarchies and naming conflicts
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:
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.zipInvoke-WebRequest https://manykarim.github.io/robotframework-essentials-web/labs/ch04-variables-keywords--import-hierarchies-and-conflicts.zip -OutFile ch04-variables-keywords--import-hierarchies-and-conflicts.zip; Expand-Archive ch04-variables-keywords--import-hierarchies-and-conflicts.zip -DestinationPath .; Remove-Item ch04-variables-keywords--import-hierarchies-and-conflicts.zipOpen 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:
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-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.
Task 1 — Qualify the ambiguous keyword with its resource name
Section titled “Task 1 — Qualify the ambiguous keyword with its resource name”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 explicitlyDone 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.resourceResource ../resources/backup.resource
*** Test Cases ***Greeting Works common.Greet worldTask 2 — Run the suite green
Section titled “Task 2 — Run the suite green”Run it:
uv run robot checksrobot checkspoetry run robot checksDone when
the test Greeting Works passes.
Check your understanding
Quick recall. Your first answer stays in this browser; the quiz never blocks your progress.
Two imported resources define a keyword with the same name. A bare call…
Robot Framework refuses an ambiguous call; qualify it with the source name, e.g.
common.Greet.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.How do you qualify a keyword to resolve the conflict?
Prefix the keyword with its library or resource name and a dot:
common.Greet.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.