Top Interview Questions
In the contemporary software development lifecycle, automated testing has become an essential practice. With increasingly complex applications and shorter release cycles, ensuring quality through manual testing alone is impractical. This is where Robot Framework comes into the picture. Robot Framework is an open-source automation framework designed to simplify testing for web, API, database, and other applications. It is widely adopted in enterprises due to its ease of use, flexibility, and compatibility with multiple programming languages.
Robot Framework is keyword-driven, meaning tests are written in a tabular format using keywords to represent actions or operations. This approach makes test cases readable, maintainable, and reusable, even for non-programmers. Moreover, it supports behavior-driven development (BDD), which emphasizes collaboration between developers, testers, and business stakeholders.
Developed initially by Nokia Networks in 2005, Robot Framework has grown into a versatile tool maintained by a robust open-source community. Its ecosystem includes numerous libraries, plugins, and integrations, making it suitable for diverse testing needs.
Robot Framework offers a range of features that make it a preferred choice for automation testing:
Robot Framework allows users to create keywords that represent actions or operations in test cases. There are two types of keywords:
Built-in keywords: Provided by the framework itself, e.g., Log, Should Be Equal, Sleep.
User-defined keywords: Custom keywords defined by testers for specific tasks.
For example, to log in to an application, a keyword like Login To Application can encapsulate multiple steps such as entering the username, password, and clicking the login button.
The framework uses a tabular format with plain text files (typically .robot files) written in ASCII, TSV, or reStructuredText formats. This makes tests readable by both technical and non-technical team members.
Example:
*** Test Cases ***
Valid Login Test
Open Browser https://example.com chrome
Input Text username_field testuser
Input Text password_field password123
Click Button login_button
Page Should Contain Welcome, testuser
Close Browser
Robot Framework is highly extensible. Users can integrate it with:
Python libraries: Custom libraries can be written in Python to extend functionality.
Java libraries: Through Jython, Java-based libraries can be used.
Remote libraries: Allow testing across networked environments.
This extensibility ensures that Robot Framework can adapt to various testing requirements.
Robot Framework supports data-driven testing, allowing testers to run the same test case with multiple input data sets. This reduces redundancy and increases coverage.
Example:
*** Test Cases ***
Login With Multiple Users
[Template] Login Template
testuser1 password1
testuser2 password2
testuser3 password3
*** Keywords ***
Login Template
[Arguments] ${username} ${password}
Open Browser https://example.com chrome
Input Text username_field ${username}
Input Text password_field ${password}
Click Button login_button
Page Should Contain Welcome, ${username}
Close Browser
Robot Framework seamlessly integrates with popular tools in the DevOps and testing ecosystem, such as:
SeleniumLibrary: For web application automation.
AppiumLibrary: For mobile app testing.
RequestsLibrary: For API testing.
DatabaseLibrary: For database validation.
Jenkins: For continuous integration.
Allure: For test reporting.
These integrations make Robot Framework versatile for end-to-end automation.
Robot Framework generates detailed HTML reports and logs automatically after test execution. These reports provide:
Test case status (pass/fail)
Step-by-step execution logs
Screenshots of failed steps
Execution time
These features help testers debug issues quickly and maintain transparency with stakeholders.
Robot Framework is cross-platform and works on Windows, macOS, and Linux. It supports multiple browsers via Selenium, such as Chrome, Firefox, Edge, and Safari, making it suitable for modern web testing requirements.
Understanding the architecture of Robot Framework helps in effectively using and extending it. The architecture can be broadly divided into the following layers:
This is where test cases are written. Test data can be in:
Robot Framework syntax (.robot)
Text files (.txt)
TSV files (.tsv)
reStructuredText (.rst)
Test cases define test suites, keywords, variables, and settings.
The core engine of Robot Framework is responsible for:
Parsing test data
Executing keywords
Managing variables
Generating reports and logs
It also handles test case control structures, such as loops and conditional statements.
Robot Framework uses libraries to provide specific functionalities:
Standard Libraries: Bundled with Robot Framework, e.g., BuiltIn, OperatingSystem, Collections.
External Libraries: Developed separately, e.g., SeleniumLibrary, AppiumLibrary.
Custom Libraries: Written in Python or Java to extend functionality as per project needs.
This layer executes test cases on the target application using libraries. Execution can be:
Sequential: Step-by-step as defined.
Parallel: Using tools like Pabot for distributed execution.
After execution, Robot Framework generates:
report.html: Summary of test execution.
log.html: Detailed step-by-step execution logs.
output.xml: Machine-readable output for further processing.
Screenshots (for failed steps when configured).
This structured output helps in debugging, reporting, and compliance.
Robot Framework consists of several components that collectively provide a robust automation solution:
A test suite is a collection of test cases grouped logically, often based on modules or functionalities. Each suite can contain multiple test cases and nested suites.
Test cases are the core executable units in Robot Framework. Each test case contains:
Test steps
Keywords
Variables
Setup and teardown instructions
Keywords represent atomic operations. They can be built-in, external, or user-defined. Keywords improve reusability and readability.
Variables allow data parametrization. They can be:
Scalar variables: Single values (${username})
List variables: Multiple values (@{usernames})
Dictionary variables: Key-value pairs (&{user})
Test cases and suites support settings such as:
Library to include external libraries
Resource to include reusable resources
Variables to include variable files
Suite Setup and Suite Teardown for pre- and post-execution steps
Test Setup and Test Teardown for test-specific pre- and post-steps
Setting up Robot Framework is straightforward, primarily because it relies on Python.
Python 3.x installed
pip (Python package installer)
Install Robot Framework:
pip install robotframework
Install SeleniumLibrary (for web automation):
pip install robotframework-seleniumlibrary
Install Browser Drivers:
Chrome: ChromeDriver
Firefox: GeckoDriver
Edge: EdgeDriver
Verify Installation:
robot --version
Robot Framework is now ready for automation testing.
Writing test cases in Robot Framework involves a few basic steps:
A simple .robot file can be created with test cases.
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Open Google And Search
Open Browser https://www.google.com chrome
Input Text name=q Robot Framework
Press Key name=q ENTER
Page Should Contain Robot Framework
Close Browser
Run the test suite using the command line:
robot path/to/testsuite.robot
After execution, check report.html and log.html for results.
To maximize efficiency and maintainability:
Modularize Keywords: Break complex actions into reusable keywords.
Use Variables: Avoid hardcoding values; use variables for URLs, credentials, and other dynamic data.
Organize Test Suites: Group related test cases logically.
Implement Logging: Use Log and Capture Page Screenshot for better debugging.
Integrate with CI/CD: Automate test execution through Jenkins or GitHub Actions.
Use Tags: Tags allow selective test execution (robot --include smoke tests.robot).
Easy to Learn: Simple syntax and tabular format make it beginner-friendly.
Versatile: Supports web, mobile, API, database, and desktop applications.
Open-Source: No licensing costs, with strong community support.
Extensible: Can integrate with various libraries and tools.
Readable and Maintainable: Keywords and structured syntax make tests clear.
Data-Driven Testing: Supports running tests with multiple datasets.
While Robot Framework is powerful, it has certain limitations:
Performance: Not suitable for high-performance or real-time testing.
GUI-Heavy Applications: Desktop applications without APIs may require complex setups.
Complex Logic: Conditional and loop logic is less intuitive compared to traditional programming languages.
Dependency on Libraries: Advanced functionalities rely heavily on external libraries.
Web Application Testing: Using SeleniumLibrary for browser automation.
API Testing: Using RequestsLibrary to validate RESTful APIs.
Mobile Testing: Using AppiumLibrary for Android and iOS apps.
Database Testing: Using DatabaseLibrary for SQL validation.
Acceptance Testing: BDD-style acceptance criteria validation.
Regression Testing: Automated regression test suites for frequent releases.
Here’s a detailed list of Robot Framework questions and answers for freshers, covering basics, keywords, libraries, and practical usage. I’ve structured them from simple to slightly advanced so freshers can prepare thoroughly for interviews.
Answer:
Robot Framework is an open-source, generic test automation framework for acceptance testing, acceptance test-driven development (ATDD), and robotic process automation (RPA). It uses keyword-driven testing, making tests readable and reusable. It is Python-based but supports other languages through libraries.
Answer:
Open-source and extensible.
Keyword-driven, data-driven, and behavior-driven testing support.
Easy integration with Selenium, Appium, Database, REST APIs.
Supports tabular test data syntax (plain text, CSV, HTML, or reStructuredText).
Cross-platform (Windows, Linux, macOS).
Detailed logs and reports generation.
Answer:
Robot Framework has a modular architecture:
Test Data: Contains test cases, keywords, and variables (in .robot or .txt files).
Test Libraries: External libraries that provide functionality (e.g., SeleniumLibrary).
Test Runner: Executes test cases using the Robot Framework engine.
Test Reports: Generates logs (log.html), reports (report.html), and outputs (output.xml).
Answer:
Test Case: A single unit of testing, describing steps to verify functionality.
Keyword: A reusable set of instructions.
Built-in Keywords: Provided by Robot Framework (e.g., Log, Should Be Equal).
User-defined Keywords: Created by testers for reuse across test cases.
Answer:
.robot – most common, uses tabular test data syntax.
.txt – plain text format, same syntax as .robot.
.tsv – tab-separated values.
.py – Python files for creating custom libraries or keywords.
Answer:
Scalar variables (${}): Store single values. Example: ${username} = admin.
List variables (@{}): Store multiple values in a list. Example: @{users} = admin, user1, user2.
Dictionary variables (&{}): Store key-value pairs. Example: &{user} = name:admin, role:tester.
Answer:
Open terminal or command prompt.
Navigate to the folder containing .robot file.
Use the command:
robot filename.robot
After execution, logs and reports will be generated in the same directory.
Answer:
A test suite is a collection of test cases.
Defined as a folder containing multiple .robot files.
Helps organize tests for modules, features, or functionality.
Test Setup and Suite Setup?Answer:
| Feature | Test Setup | Suite Setup |
|---|---|---|
| Scope | Runs before each test case | Runs once before the test suite |
| Use | Initialize test-specific data | Initialize resources for all tests in the suite |
| Example | Open browser for a single test | Launch database connection before all tests |
Built-in Library and External Library?Answer:
Built-in Library: Comes with Robot Framework by default (e.g., BuiltIn, Collections, String).
External Library: Needs installation, extends functionality (e.g., SeleniumLibrary, RequestsLibrary).
Answer:
SeleniumLibrary is an external library used for web automation testing.
Supports opening browsers, clicking elements, filling forms, handling alerts, and verification.
Common keywords: Open Browser, Click Element, Input Text, Wait Until Element Is Visible.
Answer:
Robot Framework supports IF-ELSE conditions using keywords:
*** Test Cases ***
Check Login
${status}= Run Keyword And Return Status Login user password
IF ${status}
Log Login Successful
ELSE
Log Login Failed
END
Answer:
For Loop (Fixed values):
*** Test Cases ***
Print Numbers
:FOR ${i} IN 1 2 3
\ Log ${i}
For Loop (List variable):
*** Test Cases ***
Print Users
@{users}= Create List user1 user2 user3
:FOR ${user} IN @{users}
\ Log ${user}
Answer:
*** Keywords ***
Login To Application
[Arguments] ${username} ${password}
Input Text id=username ${username}
Input Text id=password ${password}
Click Button id=login
Call keyword in test case:
*** Test Cases ***
Valid Login Test
Login To Application admin admin123
Answer:
Use [Arguments] in keyword section.
*** Keywords ***
Add Numbers
[Arguments] ${num1} ${num2}
${sum}= Evaluate ${num1}+${num2}
Log ${sum}
Answer:
Implicit wait: Selenium handles element detection delays automatically.
Explicit wait: Using keywords like Wait Until Element Is Visible, Wait Until Page Contains.
Sleep: Sleep 5s to pause execution for 5 seconds.
Answer:
Tags categorize or filter tests.
Syntax:
*** Test Cases ***
Login Test
[Tags] smoke regression
Log Running login test
Run tests with specific tags:
robot --include smoke tests/
Answer:
Run Keyword And Expect Error: Handles expected failures.
Run Keyword And Ignore Error: Continues execution even if keyword fails.
Screenshot on failure (with SeleniumLibrary): Capture Page Screenshot.
Answer:
*** Settings ***
Library SeleniumLibrary
Library Collections
Library OperatingSystem
Log and Print keywords?Answer:
Log: Outputs messages to the Robot Framework log and report.
Print: Outputs messages to the console only.
Answer:
By default, Robot Framework generates:
log.html → Detailed execution logs
report.html → Test summary
output.xml → Machine-readable execution results
Command:
robot filename.robot
Answer:
| Feature | Robot Framework | Selenium |
|---|---|---|
| Type | Test automation framework | Browser automation tool |
| Scope | Supports keyword-driven and data-driven testing | Only web automation |
| Reports | Built-in reports & logs | No built-in reporting |
| Libraries | Can integrate Selenium, API, DB | Only web browser interaction |
Answer:
Install Robot Framework and dependencies on Jenkins server.
Create a Jenkins job → Add build step: Execute shell/command → Run Robot tests:
robot -d results tests/
Install Robot Framework plugin for Jenkins to visualize reports.
Answer:
SeleniumLibrary – Web testing
AppiumLibrary – Mobile automation
DatabaseLibrary – Database testing
RequestsLibrary – API testing
OperatingSystem – File/folder operations
Collections – List/dictionary handling
Answer:
Use Choose File keyword in SeleniumLibrary:
*** Test Cases ***
Upload File Test
Open Browser https://example.com/upload chrome
Choose File id=fileInput /path/to/file.txt
Click Button id=uploadButton
Answer:
Use descriptive test case names.
Reuse keywords for common steps.
Use variables to avoid hardcoding.
Use tags for filtering.
Maintain modular test suites for scalability.
Generate reports regularly for review.
Answer:
Store test scripts in a Git repository.
Pull latest code before execution.
Use versioning to track changes.
Combine with CI/CD tools like Jenkins or GitHub Actions.
Answer:
Use XPath or CSS selectors that can handle dynamic IDs.
Example:
Click Element xpath=//button[contains(text(),'Submit')]
Answer:
Robot Framework can be used for Robotic Process Automation, automating repetitive tasks such as Excel manipulation, web forms, email handling, and file operations.
Answer:
Yes, using libraries like RequestsLibrary.
*** Test Cases ***
Get API Response
Create Session myapi https://reqres.in
${resp}= Get Request myapi /api/users/2
Status Should Be 200
Log ${resp.json()}
Run Keyword and Run Keyword And Return Status?Answer:
Run Keyword: Executes a keyword. If it fails, the test case fails.
Run Keyword And Return Status: Executes a keyword and returns True if successful, False if failed, without failing the test case.
Example:
${status}= Run Keyword And Return Status Login admin pass
IF ${status}
Log Login success
ELSE
Log Login failed
END
Variables table in Robot Framework?Answer:
The Variables table is used to store reusable values in a test suite.
Example:
*** Variables ***
${URL} https://example.com
${USERNAME} admin
${PASSWORD} pass123
Answer:
Command line:
robot testfile.robot
Using tags:
robot --include smoke testfile.robot
Through Python script:
from robot import run
run('testfile.robot')
Through CI/CD tools: Jenkins, GitHub Actions.
Answer:
Using Variables: ${var}
Using Variable files (Python):
# variables.py
URL = "https://example.com"
USERNAME = "admin"
*** Settings ***
Variables variables.py
Using Command-line variables:
robot --variable URL:https://example.com testfile.robot
Fail and Fatal Error keywords?Answer:
| Keyword | Behavior |
|---|---|
| Fail | Fails the current test case but continues the suite |
| Fatal Error | Fails the test suite execution completely |
Answer:
Using SeleniumLibrary keywords:
*** Test Cases ***
Handle Alert
Open Browser https://example.com chrome
Click Button id=alertBtn
Alert Should Be Present
Confirm Action # clicks OK
Dismiss Alert # clicks Cancel
Answer:
Using DatabaseLibrary
*** Settings ***
Library DatabaseLibrary
*** Test Cases ***
Database Connection Test
Connect To Database pymysql dbname user password host
${result}= Query SELECT * FROM users
Log ${result}
Disconnect From Database
Keyword Driven and Data Driven testing in Robot Framework?Answer:
Keyword Driven: Focuses on reusable keywords. Test case = sequence of keywords.
Data Driven: Focuses on running same test with multiple data sets using variables or external CSV/Excel.
Answer:
Using RPA.Excel.Application or ExcelLibrary
*** Settings ***
Library RPA.Excel.Application
*** Test Cases ***
Read Excel Data
Open Workbook data.xlsx
${value}= Read Cell Value Sheet1 A1
Log ${value}
Close Workbook
Answer:
Use Wait Until Element Is Visible or Wait Until Page Contains
Example:
Wait Until Element Is Visible id=submitBtn 10s
Avoid Sleep unless necessary, as it’s static wait.
Answer:
Use Log to print variable values.
Use BuiltIn.Breakpoint to pause execution and inspect.
Check log.html for detailed step-by-step execution.
Suite Teardown and Test Teardown?Answer:
| Feature | Test Teardown | Suite Teardown |
|---|---|---|
| Runs before | After each test case | After all test cases in the suite |
| Scope | Test case | Test suite |
| Use | Clean up test-specific data | Clean up resources like DB connections, browsers |
Answer:
SeleniumLibrary automatically captures screenshots using Capture Page Screenshot.
Can be done in Test Teardown:
*** Test Cases ***
Test With Screenshot
[Teardown] Capture Page Screenshot
Answer:
*** Test Cases ***
Open Multiple Browsers
Open Browser https://example.com chrome
Open Browser https://example.com firefox
Switch Browser 1 # Switch to first browser
Close Browser 2 # Close second browser
Answer:
Using RequestsLibrary:
*** Settings ***
Library RequestsLibrary
*** Test Cases ***
Get User API Test
Create Session myapi https://reqres.in
${resp}= Get Request myapi /api/users/2
Status Should Be 200
Log ${resp.json()}
Answer:
*** Test Cases ***
Check Users
@{users}= Create List user1 user2 user3
:FOR ${user} IN @{users}
\ ${status}= Run Keyword And Return Status Login ${user} pass123
\ IF ${status}
\ Log ${user} login success
\ ELSE
\ Log ${user} login failed
\ END
Answer:
Use variable files for different environments.
Example: dev_variables.py, prod_variables.py
robot --variablefile dev_variables.py tests/
robot --variablefile prod_variables.py tests/
Answer:
robot --include smoke tests/
robot --exclude regression tests/
Answer:
Create a Python class with functions:
# mylibrary.py
class MyLibrary:
def add_numbers(self, a, b):
return a + b
Import in Robot Framework:
*** Settings ***
Library mylibrary.py
*** Test Cases ***
Add Numbers Test
${result}= Add Numbers 10 20
Log ${result}
Answer:
Not understanding keyword-driven testing.
Hardcoding variables instead of using ${} or @{}.
Forgetting setup and teardown concepts.
Not using tags for filtering tests.
Ignoring logs and reports during debugging.
Overusing Sleep instead of dynamic waits.
Answer:
In real-time projects, Robot Framework is used to implement keyword-driven, data-driven, and hybrid frameworks.
Structure:
Test Suites: Organized by modules or features.
Test Cases: Reusable and maintainable, often using keywords from resource files.
Resource Files: Contain reusable keywords.
Variables Files: Environment-specific data.
Libraries: SeleniumLibrary for web, RequestsLibrary for APIs, DatabaseLibrary for DB, RPA libraries for desktop automation.
Integration: CI/CD pipelines, test management tools, and reporting.
Answer:
A hybrid framework combines multiple approaches:
Keyword-driven: Test steps are modular and reusable.
Data-driven: The same test can run with multiple datasets.
Behavior-driven (BDD-like): Using descriptive keywords that resemble business logic.
Benefits: High reusability, easy maintenance, and clarity for non-technical users.
Answer:
Use variable files per environment (dev_variables.py, qa_variables.py, prod_variables.py).
Example:
# dev_variables.py
URL = "https://dev.example.com"
USERNAME = "dev_user"
PASSWORD = "dev_pass"
Command line execution:
robot --variablefile dev_variables.py tests/
Can also use command-line variables or JSON/Excel data files.
Answer:
Store common actions in resource files.
*** Keywords ***
Login To Application
[Arguments] ${username} ${password}
Input Text id=username ${username}
Input Text id=password ${password}
Click Button id=login
Call across multiple test cases using:
*** Settings ***
Resource resources/common_keywords.robot
Answer:
Use dynamic XPath or CSS selectors.
Click Element xpath=//button[contains(text(),'${button_name}')]
Use Wait Until Element Is Visible or Wait Until Page Contains for dynamic loading elements.
Leverage loops and conditions for multiple dynamic elements.
Answer:
Configure Robot Framework environment in Jenkins.
Create Jenkins job → Add Execute shell/build step:
robot -d results tests/
Install Robot Framework plugin to display report.html and log.html in Jenkins.
Use post-build actions for notifications on failures.
For GitHub Actions, use robotframework/robotframework Docker image in workflow YAML.
Answer:
Use Pabot: A parallel executor for Robot Framework.
pabot --processes 4 tests/
Benefits: Reduces execution time, runs independent test suites concurrently.
Best practices: Avoid shared resources unless properly isolated.
Answer:
Using RequestsLibrary for REST APIs.
*** Test Cases ***
Get User Details
Create Session api https://reqres.in
${response}= Get Request api /api/users/2
Status Should Be 200
Should Contain ${response.json()['data']['email']} "@"
Supports GET, POST, PUT, DELETE, headers, authentication, JSON schema validation.
Answer:
Using DatabaseLibrary or custom Python libraries.
Connect To Database pymysql dbname user password host
${result}= Query SELECT * FROM users WHERE status='active'
Should Not Be Empty ${result}
Disconnect From Database
Verify data after UI/API actions (end-to-end testing).
Answer:
Use @{list}, CSV, Excel, or JSON to feed test data.
Example:
*** Test Cases ***
Login With Multiple Users
[Template] Login Test
admin admin123
user1 pass1
user2 pass2
*** Keywords ***
Login Test
[Arguments] ${username} ${password}
Input Text id=username ${username}
Input Text id=password ${password}
Click Button id=login
Answer:
Keywords:
Run Keyword And Ignore Error
Run Keyword And Return Status
Run Keyword And Expect Error
Example:
${status}= Run Keyword And Return Status Click Element id=nonexistent
IF not ${status}
Log Element not found
END
Answer:
File upload: Choose File (SeleniumLibrary)
Choose File id=fileInput /path/to/file.txt
Click Button id=upload
File download: Use Get Element Attribute or check folder existence using OperatingSystem library.
Answer:
Use Log, Log To Console, and BuiltIn logging levels (INFO, WARN, DEBUG).
Capture screenshots on failure.
Generate report.html, log.html, and output.xml.
Use custom loggers for critical data.
Answer:
Parameterize browsers using variables:
*** Variables ***
${BROWSER} chrome
*** Test Cases ***
Open Browser Test
Open Browser https://example.com ${BROWSER}
Integrate with Selenium Grid for parallel cross-browser execution.
Answer:
Create a Python class with reusable methods:
# custom_lib.py
class CustomLib:
def add_numbers(self, a, b):
return a + b
Import in Robot:
*** Settings ***
Library custom_lib.py
*** Test Cases ***
Add Numbers Test
${result}= Add Numbers 10 20
Log ${result}
Answer:
Use loops, XPath/CSS locators, and conditions:
*** Test Cases ***
Read Table
@{rows}= Get WebElements xpath=//table[@id='data']/tbody/tr
:FOR ${row} IN @{rows}
\ ${text}= Get Text ${row}
\ Log ${text}
Answer:
Use RPA Framework libraries (RPA.Excel.Application, RPA.FileSystem, RPA.Desktop).
Automate tasks like:
Excel read/write
File handling
Desktop applications
Web data scraping
Answer:
Modular test suite structure:
tests/ → Feature-wise test cases
resources/ → Reusable keywords
variables/ → Environment variables
Use tags for filtering (smoke, regression)
Use Pabot for parallel execution.
Answer:
Integrate Robot Framework with Jenkins/GitHub Actions
Run tests automatically on code commits/merges
Store logs and reports in CI/CD artifacts
Configure notifications (email/Slack) for failures
Answer:
Use parallel execution (Pabot)
Avoid unnecessary waits; use dynamic waits
Use modular reusable keywords
Minimize browser launches by grouping tests in suites
Cache data or session if possible
Answer:
Use environment-specific variable files:
robot --variablefile dev_variables.py tests/
robot --variablefile prod_variables.py tests/
Maintain environment details in JSON or Excel, read dynamically using keywords.
Example:
*** Settings ***
Variables ${ENVIRONMENT}.py
This allows easy switching without modifying test scripts.
Answer:
Break tests into atomic keywords: small reusable units
Create higher-level keywords that call atomic ones
*** Keywords ***
Login
Input Username
Input Password
Click Login Button
Input Username
[Arguments] ${username}
Input Text id=username ${username}
Input Password
[Arguments] ${password}
Input Text id=password ${password}
Benefits: Easier maintenance, clear test flows.
Answer:
Use RequestsLibrary for APIs and DatabaseLibrary for DB.
Example: Verify that user creation via API is reflected in DB:
Create User API
Create Session api https://api.example.com
${resp}= Post Request api /users {"name": "John"}
Status Should Be 201 ${resp.status_code}
Verify User In DB
Connect To Database pymysql dbname user password host
${result}= Query SELECT * FROM users WHERE name='John'
Should Not Be Empty ${result}
Disconnect From Database
Answer:
Use SeleniumLibrary + Pabot or Selenium Grid
Parameterize browsers and OS:
*** Variables ***
${BROWSER} chrome
${PLATFORM} windows
*** Test Cases ***
Open Browser Test
Open Browser https://example.com ${BROWSER}
Integrate with Docker containers or cloud grids like BrowserStack/Sauce Labs.
Answer:
Store test data in CSV, Excel, or JSON
Iterate using FOR loops or Test Template
*** Test Cases ***
User API Test
[Template] Validate User API
data1.json
data2.json
*** Keywords ***
Validate User API
[Arguments] ${datafile}
${data}= Get File ${datafile}
${resp}= Post Request api /users ${data}
Status Should Be 201
Answer:
Avoid Sleep; use dynamic waits:
Wait Until Element Is Visible id=dynamicElement 10s
Wait Until Page Contains Element xpath=//div[@id='ajaxContent'] 15s
Combine with Run Keyword And Ignore Error for optional elements.
Answer:
Use Pabot with --argumentfile to manage dependent tests
Ensure independent tests run in parallel; dependent tests remain sequential
Example: Login tests can run parallel, but order-sensitive data modification tests should run sequentially
Answer:
Organize suites by modules or features
Use resource files and variable files
Use tags for selective execution (smoke, regression)
Use parallel execution for independent tests
Use dynamic variable injection to avoid hardcoding
Answer:
Do not hardcode credentials
Use environment variables or encrypted variable files
Example:
*** Variables ***
${USERNAME} ${ENV_USERNAME}
${PASSWORD} ${ENV_PASSWORD}
Use CI/CD secrets or Vault for production environments
Answer:
Use different log levels: INFO, DEBUG, WARN
Capture screenshots on failure
Generate custom reports using rebot tool
Example:
rebot --report report.html --log log.html --output output.xml results/
Store logs in CI/CD for monitoring
Answer:
Use dynamic waits for asynchronous operations (AJAX, delayed API response)
Use Wait Until Keyword Succeeds for retry mechanism:
Wait Until Keyword Succeeds 1 min 5 sec Element Should Be Visible id=dynamic
Answer:
Use OperatingSystem library:
*** Test Cases ***
File Operations
Create File test.txt content
File Should Exist test.txt
Remove File test.txt
Use RPA.FileSystem for advanced RPA tasks
Answer:
Create Python listener to handle events during execution
Example: log extra information or trigger notifications
class MyListener:
ROBOT_LISTENER_API_VERSION = 2
def start_test(self, name, attrs):
print(f"Starting test: {name}")
Attach during execution:
robot --listener mylistener.py tests/
Answer:
Maintain tests in Git
Use branches for different features/environments
Use CI/CD for automated execution on commits/merges
Track test changes and maintain history for auditing
Answer:
Use external data sources: Excel, CSV, JSON, databases
Separate test logic from test data
Parameterize using Test Template and FOR loops
Answer:
Example: automate Excel, PDF, Email, or File operations using Python libraries:
# excel_lib.py
import openpyxl
class ExcelLib:
def read_cell(self, file, sheet, row, col):
wb = openpyxl.load_workbook(file)
return wb[sheet].cell(row=row, column=col).value
Import as library and use as keyword
Answer:
Use SMTP library or CI/CD email plugin
Send report.html and log.html as attachments
Send Email
[Arguments] ${to} ${subject} ${body}
Send Email ${to} ${subject} ${body} attachments=report.html
Answer:
Use contains(), starts-with() in XPath:
Click Element xpath=//div[contains(@class,'button') and text()='Submit']
Use variables for dynamic IDs
${button_id}= Set Variable btn_${user_id}
Click Element id=${button_id}
Answer:
Use Retry Keyword or Wait Until Keyword Succeeds
Wait Until Keyword Succeeds 1 min 5 sec Click Element id=flakyButton
Helps stabilize intermittent failures
Answer:
Use Docker to run tests in isolated environments
Example Dockerfile:
FROM python:3.10
RUN pip install robotframework robotframework-seleniumlibrary
COPY tests /tests
CMD ["robot", "/tests"]
Ensures environment consistency