Automated Login Tests with Robot Framework
Build a keyword-driven browser test suite that automates login scenarios.
Introduction
30 Second Summary
Every time you change a login page, someone has to click through it again. Type a username, type a password, hit the button, check the result. Now multiply that by six different scenarios. Manual testing eats time and misses things.
In this project, you will build an automated test suite that opens a real browser, tests a login page with valid and invalid credentials, and generates a report showing exactly what passed and what failed.
What You'll Build
When you run your finished test suite, Chrome launches on its own, types credentials into a login form, clicks the submit button, and checks the result. One command in the terminal, seven scenarios tested, and a detailed HTML report ready to show off.
By the end of this project, you'll have:
- A single command that launches Chrome and runs multiple login scenarios automatically, including valid credentials, wrong passwords, and empty fields.
- A clean HTML test report with pass/fail results and execution times that you can show employers as proof of your testing skills.
- Reusable custom keywords in a resource file (the Robot Framework equivalent of TOSCA modules) that you can adapt for testing any web application.
- Secret Mission: Add test tagging and selective execution to run only smoke tests or regression tests on demand.
Are there any prerequisites?
None. This project includes full setup instructions for Python, Robot Framework, and all required tools. You just need a Windows computer with VS Code installed.
Before We Start
Before we dive in, let's lock in what you're about to build and why it matters for your test automation journey. This step is your moment to commit to the goal before any tools are installed.
Install Python and Robot Framework
Your automated test suite needs two things to run: a programming language that powers it behind the scenes, and a test framework that gives you the tools to write tests in plain English.
In this step, you'll install Python (the engine), Robot Framework (the test automation framework), and a VS Code extension that gives you syntax highlighting and autocomplete for your test files.
In this step, get ready to:
- Install Python 3.13 on your machine.
- Install Robot Framework and SeleniumLibrary.
- Install the Robot Framework Language Server extension in VS Code.
Install Python 3.13
Python is the runtime that Robot Framework runs on top of. Without it installed on your machine, none of your test commands will work.
- Open a terminal in VS Code by pressing Ctrl+` (the backtick key, usually above Tab).
- Check if Python is already installed by running this command:
python --version
✔️ I see version 3.13 or higher
You're all set. Python is ready to go. Skip ahead to the next substep.
ⓧ I see an older version
You have Python installed, but you need version 3.13 for this project. Follow the install steps below to get the correct version.
- Open your browser and go to python.org/downloads/windows/.
- Click the download link for Python 3.13.15 (the latest stable release).
- Run the installer once it downloads.
- On the first page of the installer, check the box labelled Add Python to PATH. This is critical. Without it, your terminal will not recognise the python command.
- Click Install Now and wait for the installation to finish.
- Close your current terminal in VS Code by clicking the trash can icon in the terminal panel.
- Open a fresh terminal with Ctrl+` and verify the new version by running:
python --version
You should see Python 3.13.15 (or a similar 3.13.x number) in the output.
Still seeing the old version?
The new Python install may not take priority over the old one in your PATH. Try uninstalling the older Python version from Settings then Apps, then restart VS Code and run python --version again.
help me fix my Python version on Windows
ⓧ Command not found
Python is not installed yet. Follow these steps to install it.
- Open your browser and go to python.org/downloads/windows/.
- Click the download link for Python 3.13.15 (the latest stable release).
- Run the installer once it downloads.
- On the first page of the installer, check the box labelled Add Python to PATH. This is critical. Without it, your terminal will not recognise the python command.
- Click Install Now and wait for the installation to finish.
- Close your current terminal in VS Code by clicking the trash can icon in the terminal panel.
- Open a fresh terminal with Ctrl+` and verify the installation by running:
python --version
You should see Python 3.13.15 (or a similar 3.13.x number) in the output.
Still seeing 'command not found'?
You likely missed the Add Python to PATH checkbox during installation. Re-run the installer, select Modify, and ensure the PATH option is checked. Then close and reopen your VS Code terminal.
help me get Python recognised in my terminal
Why does the PATH checkbox matter?
Your terminal only knows about programs listed in a special system variable called PATH. If Python is not in your PATH, the terminal cannot find it when you type python. Checking that box during installation adds Python's location automatically.
Install Robot Framework and SeleniumLibrary
Now that Python is working, you can use its package manager (pip) to install Robot Framework and the browser testing library.
- Install both packages by running this command in your terminal:
pip install robotframework==7.4.2 robotframework-seleniumlibrary
What does this command do?
pip install robotframework==7.4.2 installs the exact version of Robot Framework this project uses. Pinning the version ensures your results match this guide.
robotframework-seleniumlibrary adds browser automation keywords like Open Browser, Click Button, and Input Text. It also includes Selenium Manager, which automatically downloads browser drivers for you.
You should see installation progress messages ending with a success confirmation. If pip installs several dependencies along the way, that is normal.
Seeing a 'pip is not recognized' error?
This means Python's Scripts folder is not in your PATH. Close VS Code entirely, reopen it, and try again. If the error persists, reinstall Python and make sure the Add Python to PATH checkbox is checked.
help me fix pip not being recognised
Install the VS Code extension and verify the full setup
A language server extension gives you syntax highlighting, autocomplete, and error checking inside your .robot files. This makes writing tests much faster than working with plain text.
- Open the Extensions panel in VS Code by pressing Ctrl+Shift+X.
- Type Robot Framework Language Server in the search bar at the top of the panel.
- Click Install on the result that appears.
Multiple results?
You may see several Robot Framework extensions. Pick the one that includes "Language Server" in its name and has a high install count. It provides the richest editing support for .robot files.
Now verify the entire toolchain is working. Before you run the next command, what do you think the output will show?
- Verify your setup by running this command in the terminal:
robot --version
You should see output like Robot Framework 7.4.2 (Python 3.13.15 on win32). This confirms Robot Framework is installed, it found the correct Python version, and everything is connected.
Seeing 'robot is not recognized'?
Close VS Code completely and reopen it. The terminal needs to reload your PATH after installing new packages. If it still fails, try running python -m robot --version as an alternative.
help me fix the robot command not being found
Your automation environment is ready. Next up, you'll write your first browser test and watch Chrome open on its own.
Write and Run Your First Browser Test
Your automation environment is ready. Python, Robot Framework, and SeleniumLibrary are all installed and verified.
Now you need to see automation in action. In this step, you will write a test that opens a real browser, navigates to a login page, and verifies the page title. Watching Chrome move on its own proves the entire toolchain works and gives you something visible within minutes.
In this step, get ready to:
- Download and start a demo login application that your tests will target.
- Write your first Robot Framework test file that opens Chrome and checks a page title.
- Run the test and review the generated HTML report.
Download and start the demo login app
Your tests need a target web application. The official Robot Framework WebDemo project provides a simple login page server built in Python.
- Move to your Desktop by running this command:
cd ~/Desktop
- Clone the WebDemo repository from GitHub by running this command:
git clone https://github.com/robotframework/WebDemo.git
You should see Git download the files and display a success message.
Seeing 'git' is not recognized?
If Git is not installed, download the ZIP manually instead. Open https://github.com/robotframework/WebDemo/archive/master.zip in your browser, save the file to your Desktop, then right-click the ZIP and select Extract All. Rename the extracted folder from WebDemo-master to WebDemo.
help me set up Git on Windows so I can clone repositories
- Move into the WebDemo folder by running:
cd WebDemo
- Start the demo login server by running:
python demoapp/server.py
The terminal will appear to hang with no output. This is normal. The server is running and waiting for requests.
What does this command do?
This starts a small Python web server on your machine at port 7272. It serves a login page that accepts the username demo and password mode. The server must stay running in this terminal while you write and run your tests.
- Open your browser and navigate to http://localhost:7272.
You should see a simple login form with username and password fields and a Login button.
Don't see the login page?
Make sure the python demoapp/server.py command is still running in the other terminal. If you closed it or pressed Ctrl+C, run it again.
Check that you typed the URL exactly as http://localhost:7272 with no trailing path.
help me get the WebDemo server running on localhost:7272
Write your first test file
With the login page running, you can write a test that opens Chrome, checks the page title, and closes the browser. This is the simplest possible browser automation test.
- Create a new project folder on your Desktop for your test files by opening a second terminal in VS Code. Press Ctrl+Shift+` to open a new terminal tab.
- Create your project folder and move into it by running these commands:
cd ~/Desktop
mkdir robot-tests
cd robot-tests
- Confirm the folder was created by running:
ls
The folder will be empty for now. That is expected.
- Create a new file called first_test.robot inside robot-tests by clicking File in the VS Code menu bar, then New File.
- When prompted for the file name, type first_test.robot and save it inside the robot-tests folder on your Desktop.
- Paste the following code into first_test.robot:
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Open Login Page
Open Browser http://localhost:7272/ Chrome
Title Should Be Login Page
Close Browser
What does this code do?
- *** Settings *** declares configuration for the test file. Library SeleniumLibrary imports all browser automation keywords.
- *** Test Cases *** starts the section where you define tests. Open Login Page is the name of your test case.
- Open Browser launches Chrome and navigates to the URL. Title Should Be checks the page title matches exactly. Close Browser shuts down the Chrome window.
- Save first_test.robot by pressing Ctrl+S.
Seeing red squiggly lines in the editor?
Make sure the Robot Framework Language Server extension is installed and enabled. It needs a moment to index SeleniumLibrary. The warnings may disappear after a few seconds.
help me fix red underlines in my .robot file in VS Code
Run the test and review your report
Your test file is saved and the demo server is still running in the other terminal. Time to see automation happen.
- In the second terminal (the one inside robot-tests), make sure you are in the robot-tests folder.
Before you run this, what do you think will happen? Will Chrome open on its own, or will you see only text output in the terminal?
- Run your first automated test by executing:
robot first_test.robot
Chrome opens on its own, navigates to the login page, and closes. The terminal displays the test result:
==============================================================================
Open Login Page | PASS |
------------------------------------------------------------------------------
First Test | 1 test, 1 passed, 0 failed
==============================================================================
What just happened?
Robot Framework read your .robot file, launched Chrome via SeleniumLibrary, checked the page title matched Login Page, then closed the browser. It also generated three output files: output.xml, log.html, and report.html.
- Open the generated HTML report by running:
start log.html
Your default browser opens the log file. You should see a green PASS result for the test case Open Login Page, with timestamps and details for each keyword that executed.
Chrome didn't open or the test failed?
Make sure the demo server is still running in your first terminal. If you accidentally closed it, go back and run python demoapp/server.py again from inside the WebDemo folder.
If you see an error about Chrome not being found, confirm Google Chrome is installed on your machine. Selenium Manager handles the driver automatically, but Chrome itself must be present.
help me fix my first Robot Framework test that failed to open Chrome
✔️ Awesome, I've got everything!
Great. Double check you have saved first_test.robot and that the terminal shows 1 test, 1 passed, 0 failed.
ⓧ I'd like to double check the full code
Here is the complete first_test.robot file. Make sure yours matches exactly:
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Open Login Page
Open Browser http://localhost:7272/ Chrome
Title Should Be Login Page
Close Browser
You just watched a browser move on its own. Next up, you will teach your test to type credentials, click the login button, and verify the result.
Automate a Complete Login Flow
Your first test proved the toolchain works. Chrome opened, checked a page title, and closed. Now it's time to do what real tests do.
A real automated test interacts with the page. It types into fields, clicks buttons, and checks whether the application responded correctly. This is exactly what TOSCA test cases do with modules and test steps.
In this step, get ready to:
- Write a test that logs in with valid credentials and verifies success.
- Write a test that logs in with invalid credentials and verifies the error.
- Run both tests and review the HTML report.
Write the valid login test
Your first test only checked a page title. A proper login test needs to type a username, type a password, click the login button, and verify the result.
- Create a new file called login_test.robot in your project folder by right-clicking in the VS Code Explorer sidebar and selecting New File.
- Paste the following code into login_test.robot:
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Valid Login
Open Browser http://localhost:7272/ Chrome
Input Text username_field demo
Input Text password_field mode
Click Button login_button
Title Should Be Welcome Page
[Teardown] Close Browser
What does this code do?
This test case automates a complete login flow using SeleniumLibrary keywords.
- Input Text username_field demo finds the username input by its HTML element ID and types "demo" into it.
- Input Text password_field mode does the same for the password field.
- Click Button login_button clicks the submit button by its ID.
- Title Should Be Welcome Page verifies the login succeeded by checking the browser's page title changed.
- [Teardown] Close Browser guarantees the browser closes even if the test fails partway through. Without it, a failed assertion would leave Chrome hanging open.
- Save login_test.robot.
- Before you run this, what do you think will happen in the browser? Will you see anything typed into the form?
- Switch to the terminal where you ran your first test (not the one running the demo server) and run this command:
robot login_test.robot
Watch Chrome open, navigate to the login page, type "demo" and "mode" into the form fields, and click the login button. The terminal shows:
1 test, 1 passed, 0 failed
Test failed or browser didn't open?
- Make sure the demo server is still running in its terminal window. Visit http://localhost:7272 in your browser to confirm.
- Check that every line inside the test case is indented with spaces (not tabs). Robot Framework uses spacing to identify keywords within a test case.
- Verify you typed username_field, password_field, and login_button exactly as shown. These are the HTML element IDs on the demo page.
Help me debug my Robot Framework login test
Add the invalid login test
Testing the happy path is only half the job. You also need to verify the application rejects bad credentials correctly.
- In login_test.robot, add the following test case below the Valid Login test (leave a blank line between them):
Invalid Login
Open Browser http://localhost:7272/ Chrome
Input Text username_field invalid
Input Text password_field wrong
Click Button login_button
Title Should Be Error Page
[Teardown] Close Browser
What does this test verify?
This test uses deliberately wrong credentials ("invalid" and "wrong") and then checks that the page title becomes "Error Page". If the app accidentally let invalid users through, this test would catch it.
Notice the same [Teardown] Close Browser pattern. Each test opens its own browser and closes it when done, keeping tests independent of each other.
In TOSCA terms, each test case here is like a separate test case in a test suite, and the [Teardown] is like a recovery scenario that runs regardless of the test outcome.
- Save login_test.robot.
- Before running, predict: how many tests do you think will execute now?
- Run the full file again:
robot login_test.robot
Chrome opens twice. The first run types "demo"/"mode" and lands on the Welcome Page. The second run types "invalid"/"wrong" and lands on the Error Page. The terminal shows:
2 tests, 2 passed, 0 failed
One test passed but the other failed?
- Check that the Invalid Login test uses Title Should Be Error Page (not "Login Page" or "Welcome Page").
- Make sure there is a blank line between the two test cases. Robot Framework uses blank lines to separate test case definitions.
- Confirm that [Teardown] Close Browser appears as the last line of each test case, indented at the same level as the other keywords.
Help me fix my invalid login test in Robot Framework
Review the HTML report
- Open report.html in your browser by double-clicking it in the VS Code Explorer sidebar.
You should see both test results listed individually with green pass indicators, execution times, and the test suite name.
Why does the report matter?
Robot Framework generates report.html and log.html after every run. The report gives a high-level pass/fail summary. The log shows every keyword that executed, with timestamps and screenshots on failure.
These reports are what you would show an employer to prove your tests run and pass. They are equivalent to TOSCA execution logs.
✔️ Awesome, I've got everything!
Great. Double check you have saved login_test.robot and confirmed both tests pass.
ⓧ I'd like to double check the full code
Here is the complete login_test.robot file. Make sure yours matches exactly:
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Valid Login
Open Browser http://localhost:7272/ Chrome
Input Text username_field demo
Input Text password_field mode
Click Button login_button
Title Should Be Welcome Page
[Teardown] Close Browser
Invalid Login
Open Browser http://localhost:7272/ Chrome
Input Text username_field invalid
Input Text password_field wrong
Click Button login_button
Title Should Be Error Page
[Teardown] Close Browser
You now have two working tests that interact with a real browser. But look at the code. Both tests repeat the same sequence: open browser, type into fields, click a button, check the title, close the browser. In the next step, you will extract those repeated steps into reusable keywords that you can call by name.
Build Reusable Keywords
Your login tests from the previous step work, but look at the duplication. Both test cases repeat the same pattern: open the browser, type into fields, click the button. Every new test you write would copy those same low-level commands.
In TOSCA, you would create reusable modules to avoid this. Robot Framework uses resource files with custom keywords for the same purpose. You define an action once, give it a descriptive name, and reuse it everywhere.
In this step, get ready to:
- Create a resource file with reusable keywords that replace repetitive Selenium commands.
- Rewrite your valid login test to read like plain English using custom keywords.
- Run the refactored test and compare its readability to the original.
Create the resource file with variables and navigation keywords
A resource file in Robot Framework is a shared library of variables and keywords that any test file can import. It is the equivalent of a TOSCA module.
- Create a new folder called login_tests inside your project folder by running this command:
mkdir login_tests
- Confirm the folder was created by running:
ls
You should see login_tests listed alongside your existing first_test.robot and login_test.robot files.
- In VS Code, create a new file called resource.robot inside the login_tests folder.
- Add the Settings, Variables, and navigation keywords by pasting this code into resource.robot:
*** Settings ***
Library SeleniumLibrary
*** Variables ***
${SERVER} http://localhost:7272
${BROWSER} Chrome
${DELAY} 0
${LOGIN URL} ${SERVER}/
${WELCOME URL} ${SERVER}/welcome.html
${ERROR URL} ${SERVER}/error.html
*** Keywords ***
Open Browser To Login Page
Open Browser ${LOGIN URL} ${BROWSER}
Maximize Browser Window
Set Selenium Speed ${DELAY}
Login Page Should Be Open
Login Page Should Be Open
Title Should Be Login Page
Go To Login Page
Go To ${LOGIN URL}
Login Page Should Be Open
What does this code do?
The Variables section stores values you would otherwise hardcode in every test. Changing the server URL or browser means editing one line instead of every test file.
- ${SERVER} is the base URL. Other variables like ${LOGIN URL} build on it automatically.
- Open Browser To Login Page is a custom keyword that wraps four Selenium steps into one readable action.
- Go To Login Page navigates back to login without reopening the browser. You will use this between test cases later.
- Save resource.robot.
Add interaction and verification keywords
The navigation keywords handle getting to the page. Now you need keywords for typing credentials, submitting the form, and checking the result.
- In resource.robot, add the following keywords directly below the Go To Login Page keyword:
Input Username
[Arguments] ${username}
Input Text username_field ${username}
Input Password
[Arguments] ${password}
Input Text password_field ${password}
Submit Credentials
Click Button login_button
Welcome Page Should Be Open
Location Should Be ${WELCOME URL}
Title Should Be Welcome Page
Error Page Should Be Open
Location Should Be ${ERROR URL}
Title Should Be Error Page
What does this code do?
- Input Username and Input Password accept an argument. The [Arguments] line lets you pass in different values each time you call the keyword.
- Submit Credentials wraps the button click. Test cases never need to know the button's HTML ID.
- Welcome Page Should Be Open and Error Page Should Be Open check both the URL and the page title. Two assertions catch more bugs than one.
- Save resource.robot. Your resource file is now complete with all the reusable keywords you need.
Seeing red underlines in VS Code?
The Robot Framework Language Server may show warnings until a test file imports this resource. The underlines will disappear once you create the test file in the next substep.
Also check that each keyword body line starts with exactly four spaces of indentation. Robot Framework uses whitespace to distinguish keyword names from their body steps.
Why is my resource.robot showing syntax errors?
✔️ Awesome, I've got everything!
Make sure you have saved resource.robot. The file should have a Settings section, a Variables section, and a Keywords section with eight keywords total.
ⓧ I'd like to double check the full code
Your login_tests/resource.robot should contain the two chunks you built above, in order:
- The Settings, Variables, and navigation keywords chunk (Settings with SeleniumLibrary, six variables, and three keywords: Open Browser To Login Page, Login Page Should Be Open, Go To Login Page).
- The interaction and verification keywords chunk (Input Username, Input Password, Submit Credentials, Welcome Page Should Be Open, Error Page Should Be Open).
Scroll up and confirm each chunk is present in your file, in that order, with no gaps between them.
Write the valid login test using custom keywords
Now you will create a test file that imports your resource and uses those keywords instead of raw Selenium commands. The test case should read like a description of what happens, not how it happens.
- Create a new file called valid_login.robot inside the login_tests folder.
- Paste the following code into valid_login.robot:
*** Settings ***
Documentation A test suite with a single test for valid login.
Resource resource.robot
Suite Teardown Close Browser
*** Test Cases ***
Valid Login
Open Browser To Login Page
Input Username demo
Input Password mode
Submit Credentials
Welcome Page Should Be Open
What does this code do?
- Resource resource.robot imports all the variables and keywords from your resource file. This is how Robot Framework shares reusable components across tests.
- Suite Teardown Close Browser closes the browser once after all tests in this file finish, instead of after each individual test.
- The test case body uses your custom keywords. No HTML element IDs, no hardcoded URLs. If the login form changes, you update resource.robot once and every test keeps working.
- Save valid_login.robot.
✔️ Awesome, I've got everything!
Make sure you have saved valid_login.robot. Double check the file is inside the login_tests folder, next to resource.robot.
ⓧ I'd like to double check the full code
*** Settings ***
Documentation A test suite with a single test for valid login.
Resource resource.robot
Suite Teardown Close Browser
*** Test Cases ***
Valid Login
Open Browser To Login Page
Input Username demo
Input Password mode
Submit Credentials
Welcome Page Should Be Open
Run the refactored test and compare readability
Your refactored test uses the exact same login flow as before, but expressed through custom keywords. Before you run it, think about what you expect to happen.
- Do you think this test will pass or fail? It uses keywords you defined yourself. If any keyword name is misspelled or the resource import path is wrong, Robot Framework will not find it.
- Run the test by executing this command in your terminal:
robot login_tests/valid_login.robot
Chrome opens, navigates to the login page, types the credentials, clicks the button, and lands on the Welcome Page. The terminal shows 1 test, 1 passed, 0 failed.
Compare the readability
Open your original login_test.robot and compare it to valid_login.robot. The original uses raw Selenium commands like Input Text username_field demo. The refactored version says Input Username demo.
Anyone can read the refactored test and understand what it does without knowing HTML element IDs. This is the power of keyword-driven testing.
Seeing a 'No keyword with name' error?
- Check that valid_login.robot and resource.robot are both inside the login_tests folder. The Resource resource.robot line expects the file in the same directory.
- Check that keyword names in your test case match the keyword names in resource.robot exactly. Spacing differences are fine, but the words must match.
- Make sure your terminal is in the project folder (one level above login_tests), not inside login_tests itself.
Help me debug why Robot Framework can't find my keywords.
- Open the generated report.html in your browser to see the test result with your custom keyword names displayed in the report.
Your reusable keywords are working. You have a resource file that any test can import, and a test case that reads like a plain-English description of the login flow. Next up, you will use these keywords to test six different invalid login scenarios without writing any new keywords.
Add Data-Driven Testing
Your valid login test reads like plain English now, thanks to the reusable keywords in resource.robot. But you only have one invalid login scenario. Real-world testing demands many variations of bad input: wrong usernames, wrong passwords, empty fields, and combinations of each.
Copying the same test case six times with different data creates a maintenance headache. Robot Framework's Test Templates let you define the test logic once and feed it multiple data sets. This is the same concept as TOSCA's data-driven test case design, where test data is separated from test steps.
In this step, get ready to:
- Create a data-driven test file with six invalid login scenarios defined as data rows.
- Implement a template keyword that runs the same test logic for each data row.
- Run the full test suite and review the combined HTML report showing all 7 tests.
Create the invalid login test file with data rows
A Test Template tells Robot Framework that every test case in the file follows the same keyword. Instead of writing out the full test logic each time, you just supply the arguments as columns of data.
- In VS Code, create a new file called invalid_login.robot inside your login_tests/ folder.
- Add the following Settings and Test Cases sections:
*** Settings ***
Documentation A test suite containing tests related to invalid login.
Resource resource.robot
Suite Setup Open Browser To Login Page
Suite Teardown Close Browser
Test Setup Go To Login Page
Test Template Login With Invalid Credentials Should Fail
*** Test Cases *** USERNAME PASSWORD
Invalid Username invalid mode
Invalid Password demo wrong
Invalid Username And Password invalid wrong
Empty Username ${EMPTY} mode
Empty Password demo ${EMPTY}
Empty Username And Password ${EMPTY} ${EMPTY}
What does this code do?
The Test Template setting declares that every test case in this file uses the keyword Login With Invalid Credentials Should Fail. You have not written that keyword yet. That comes next.
Each test case name (like Invalid Username) is followed by columns of data. These columns map to the keyword's arguments: USERNAME and PASSWORD.
The Suite Setup opens the browser once for all tests. Test Setup navigates back to the login page before each individual test case. This makes the suite faster because the browser only opens once.
- Save invalid_login.robot.
Why ${EMPTY} instead of leaving the field blank?
Robot Framework uses whitespace to separate columns. If you left a field truly blank, Robot Framework would not know where one column ends and the next begins. The built-in variable ${EMPTY} explicitly represents an empty string while keeping the column structure intact.
Implement the template keyword
The data rows tell Robot Framework what to test, but the template keyword defines how to test it. This keyword receives the username and password from each row and runs the same login-and-verify sequence.
- In invalid_login.robot, add the following Keywords section below the Test Cases section:
*** Keywords ***
Login With Invalid Credentials Should Fail
[Arguments] ${username} ${password}
Input Username ${username}
Input Password ${password}
Submit Credentials
Error Page Should Be Open
What does this keyword do?
This keyword accepts ${username} and ${password} as arguments. For each test case row, Robot Framework calls this keyword with that row's data.
The keyword reuses Input Username, Input Password, Submit Credentials, and Error Page Should Be Open from your resource.robot file. You write the logic once. Robot Framework runs it six times with six different inputs.
- Save invalid_login.robot.
Run the full test suite and review results
Your login_tests/ folder now contains two test files: valid_login.robot (1 test) and invalid_login.robot (6 tests). Running Robot Framework against the entire folder executes every test file inside it.
- Before you run this, predict: how many total tests should execute across both files?
- In your second terminal (the one not running the demo server), make sure you are in your project folder and run:
robot login_tests/
Chrome opens, navigates to the login page, and runs through all seven scenarios. The terminal shows 7 tests, 7 passed, 0 failed.
- Open report.html in your browser by double-clicking it in your project folder.
You should see all seven test cases listed individually with their pass/fail status and execution times. Each invalid login scenario appears by name (like Invalid Username and Empty Password), making it easy to spot which scenario failed if one ever does.
Seeing fewer than 7 tests?
Make sure both valid_login.robot and invalid_login.robot are inside the login_tests/ folder. Robot Framework only picks up .robot files in the directory you point it to.
If you see errors about Login With Invalid Credentials Should Fail not being found, check that the *** Keywords *** section is in invalid_login.robot and the keyword name matches the Test Template setting exactly.
Help me debug my Robot Framework data-driven tests
How does this compare to TOSCA?
In TOSCA, you separate test data from test steps using the Test Data Management feature. You define one test case and attach a data source with multiple rows. Robot Framework's Test Template achieves the same result. The template keyword is your test step logic. The data rows are your test data set.
✔️ Awesome, I've got everything!
Great. Double check you have saved invalid_login.robot and confirmed all 7 tests pass.
ⓧ I'd like to double check the full code
Here is the complete invalid_login.robot file. Confirm yours matches exactly:
*** Settings ***
Documentation A test suite containing tests related to invalid login.
Resource resource.robot
Suite Setup Open Browser To Login Page
Suite Teardown Close Browser
Test Setup Go To Login Page
Test Template Login With Invalid Credentials Should Fail
*** Test Cases *** USERNAME PASSWORD
Invalid Username invalid mode
Invalid Password demo wrong
Invalid Username And Password invalid wrong
Empty Username ${EMPTY} mode
Empty Password demo ${EMPTY}
Empty Username And Password ${EMPTY} ${EMPTY}
*** Keywords ***
Login With Invalid Credentials Should Fail
[Arguments] ${username} ${password}
Input Username ${username}
Input Password ${password}
Submit Credentials
Error Page Should Be Open
You now have a complete, data-driven test suite that covers the login page from every angle. Adding a seventh scenario means adding one line of data, not rewriting an entire test case. Next up, the Secret Mission challenges you to organize these tests with tags so you can run just the critical ones on demand.
Secret mission
Add Test Tagging and Selective Execution
Real test suites have hundreds of tests. Running all of them every time wastes time. In this mission, you'll add smoke and regression tags to your tests and learn to run only the subset you need, just like TOSCA's execution list filters.
Clean Up Your Resources
Clean Up Your Resources
This project runs entirely locally, so there are no ongoing costs. Decide whether to keep your resources installed for future practice, pause the running server, or delete everything entirely.
Resources you used:
- WebDemo demo server (running on http://localhost:7272).
- Project files (first_test.robot, login_test.robot, login_tests/ folder).
- Downloaded WebDemo folder.
- Robot Framework 7.4.2 and SeleniumLibrary (pip packages).
- Robot Framework Language Server VS Code extension.
- Python 3.13.
Keep everything running
No action needed. Choose this if you plan to keep practising with Robot Framework or preparing for your TOSCA certification.
- Python, Robot Framework, and SeleniumLibrary take minimal disk space and have no ongoing cost.
- The WebDemo server uses negligible memory while running.
- You can re-run your test suite any time with robot login_tests/.
Pause - I'll come back to this later
Stop the running server to free up the terminal. Everything else stays installed and ready for when you return.
- Switch to the terminal where the WebDemo server is running.
- Press Ctrl+C to stop the server.
- When you come back, navigate to your WebDemo folder and run python demoapp/server.py to start it again.
Delete - I don't want to use this again
Remove all project resources and start fresh. Follow each step below.
- Stop the WebDemo server by pressing Ctrl+C in its terminal window.
- Delete your project files and the WebDemo folder. Open the folder on your Desktop that contains your .robot files, select everything, and delete it. Alternatively, run this in your terminal from the Desktop:
cd ~\Desktop
rmdir /s /q WebDemo
del first_test.robot
del login_test.robot
rmdir /s /q login_tests
- Uninstall Robot Framework and SeleniumLibrary by running this command:
pip uninstall robotframework robotframework-seleniumlibrary
Type y and press Enter when prompted to confirm each package removal.
- Remove the Robot Framework Language Server extension in VS Code. Open the Extensions panel (Ctrl+Shift+X), find Robot Framework Language Server, and click Uninstall.
- Uninstall Python 3.13. Open Settings (press the Windows key, type Settings), go to Apps, then Installed apps. Search for Python, select the Python 3.13 entry, and click Uninstall.
- Also delete the generated report files (log.html, report.html, output.xml) if any remain on your Desktop.
Nice Work!
Nice Work!
You just built a complete automated login test suite from scratch using Robot Framework. You have a working, modular, data-driven browser automation project that proves you understand the fundamentals of keyword-driven test automation.
Here's what you accomplished:
- Written automated browser tests that open Chrome, type credentials, click buttons, and verify page results with no manual interaction.
- Built reusable keywords in a resource file (the Robot Framework equivalent of TOSCA modules) so your test cases read like plain English.
- Created data-driven tests using Test Templates (the equivalent of TOSCA test data management) that run six invalid login scenarios from a single keyword definition.
- Secret Mission: Organized tests with tags and ran selective test execution using --include and --exclude filters (the equivalent of TOSCA execution lists).
Ready to quiz yourself?