Robot Framework

Robot Framework

Top Interview Questions

About Robot Framework

 

Introduction

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.


Key Features of Robot Framework

Robot Framework offers a range of features that make it a preferred choice for automation testing:

1. Keyword-Driven 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.

2. Easy-to-Read Syntax

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

3. Extensible Architecture

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.

4. Data-Driven Testing

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

5. Integration with Other Tools

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.

6. Rich Reporting and Logging

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.

7. Platform and Browser Independence

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.


Architecture of Robot Framework

Understanding the architecture of Robot Framework helps in effectively using and extending it. The architecture can be broadly divided into the following layers:

1. Test Data Layer

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.

2. Framework Core

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.

3. Libraries

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.

4. Test Execution Layer

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.

5. Output Layer

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.


Components of Robot Framework

Robot Framework consists of several components that collectively provide a robust automation solution:

1. Test Suites

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.

2. Test Cases

Test cases are the core executable units in Robot Framework. Each test case contains:

  • Test steps

  • Keywords

  • Variables

  • Setup and teardown instructions

3. Keywords

Keywords represent atomic operations. They can be built-in, external, or user-defined. Keywords improve reusability and readability.

4. Variables

Variables allow data parametrization. They can be:

  • Scalar variables: Single values (${username})

  • List variables: Multiple values (@{usernames})

  • Dictionary variables: Key-value pairs (&{user})

5. Settings

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


Installation and Setup

Setting up Robot Framework is straightforward, primarily because it relies on Python.

Prerequisites

  • Python 3.x installed

  • pip (Python package installer)

Installation Steps

  1. Install Robot Framework:

pip install robotframework
  1. Install SeleniumLibrary (for web automation):

pip install robotframework-seleniumlibrary
  1. Install Browser Drivers:

    • Chrome: ChromeDriver

    • Firefox: GeckoDriver

    • Edge: EdgeDriver

  2. Verify Installation:

robot --version

Robot Framework is now ready for automation testing.


Writing and Executing Tests

Writing test cases in Robot Framework involves a few basic steps:

1. Create a Test Suite

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

2. Execute Test Cases

Run the test suite using the command line:

robot path/to/testsuite.robot

After execution, check report.html and log.html for results.


Best Practices in Robot Framework

To maximize efficiency and maintainability:

  1. Modularize Keywords: Break complex actions into reusable keywords.

  2. Use Variables: Avoid hardcoding values; use variables for URLs, credentials, and other dynamic data.

  3. Organize Test Suites: Group related test cases logically.

  4. Implement Logging: Use Log and Capture Page Screenshot for better debugging.

  5. Integrate with CI/CD: Automate test execution through Jenkins or GitHub Actions.

  6. Use Tags: Tags allow selective test execution (robot --include smoke tests.robot).


Advantages of Robot Framework

  1. Easy to Learn: Simple syntax and tabular format make it beginner-friendly.

  2. Versatile: Supports web, mobile, API, database, and desktop applications.

  3. Open-Source: No licensing costs, with strong community support.

  4. Extensible: Can integrate with various libraries and tools.

  5. Readable and Maintainable: Keywords and structured syntax make tests clear.

  6. Data-Driven Testing: Supports running tests with multiple datasets.


Limitations

While Robot Framework is powerful, it has certain limitations:

  1. Performance: Not suitable for high-performance or real-time testing.

  2. GUI-Heavy Applications: Desktop applications without APIs may require complex setups.

  3. Complex Logic: Conditional and loop logic is less intuitive compared to traditional programming languages.

  4. Dependency on Libraries: Advanced functionalities rely heavily on external libraries.


Use Cases

  1. Web Application Testing: Using SeleniumLibrary for browser automation.

  2. API Testing: Using RequestsLibrary to validate RESTful APIs.

  3. Mobile Testing: Using AppiumLibrary for Android and iOS apps.

  4. Database Testing: Using DatabaseLibrary for SQL validation.

  5. Acceptance Testing: BDD-style acceptance criteria validation.

  6. Regression Testing: Automated regression test suites for frequent releases.

Fresher Interview Questions

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.


1. What is Robot Framework?

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.


2. What are the key features of Robot Framework?

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.


3. Explain the architecture of Robot Framework.

Answer:
Robot Framework has a modular architecture:

  1. Test Data: Contains test cases, keywords, and variables (in .robot or .txt files).

  2. Test Libraries: External libraries that provide functionality (e.g., SeleniumLibrary).

  3. Test Runner: Executes test cases using the Robot Framework engine.

  4. Test Reports: Generates logs (log.html), reports (report.html), and outputs (output.xml).


4. What are test cases and keywords in Robot Framework?

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.


5. What file formats are supported by Robot Framework?

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.


6. What are the types of variables in Robot Framework?

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.


7. How do you run a Robot Framework test?

Answer:

  1. Open terminal or command prompt.

  2. Navigate to the folder containing .robot file.

  3. Use the command:

    robot filename.robot
    
  4. After execution, logs and reports will be generated in the same directory.


8. What is a test suite in Robot Framework?

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.


9. What is the difference between 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

10. What is the difference between 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).


11. What is SeleniumLibrary in Robot Framework?

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.


12. How do you handle conditional statements in Robot Framework?

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

13. How do you loop in Robot Framework?

Answer:

  1. For Loop (Fixed values):

*** Test Cases ***
Print Numbers
    :FOR  ${i}  IN  1  2  3
    \  Log  ${i}
  1. For Loop (List variable):

*** Test Cases ***
Print Users
    @{users}=  Create List  user1  user2  user3
    :FOR  ${user}  IN  @{users}
    \  Log  ${user}

14. How do you create reusable keywords?

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

15. How do you pass arguments to keywords?

Answer:

  • Use [Arguments] in keyword section.

*** Keywords ***
Add Numbers
    [Arguments]  ${num1}  ${num2}
    ${sum}=  Evaluate  ${num1}+${num2}
    Log  ${sum}

16. How do you handle waits in Robot Framework?

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.


17. What are tags in Robot Framework?

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/

18. How do you handle test failures?

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.


19. How do you import libraries in Robot Framework?

Answer:

*** Settings ***
Library  SeleniumLibrary
Library  Collections
Library  OperatingSystem

20. What is the difference between Log and Print keywords?

Answer:

  • Log: Outputs messages to the Robot Framework log and report.

  • Print: Outputs messages to the console only.


21. How do you generate reports and logs?

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

22. What is the difference between Robot Framework and Selenium?

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

23. How do you integrate Robot Framework with Jenkins?

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.


24. What are some common Robot Framework libraries?

Answer:

  • SeleniumLibrary – Web testing

  • AppiumLibrary – Mobile automation

  • DatabaseLibrary – Database testing

  • RequestsLibrary – API testing

  • OperatingSystem – File/folder operations

  • Collections – List/dictionary handling


25. How do you handle file uploads in Robot Framework?

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

26. What are some best practices for Robot Framework?

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.


27. How do you integrate Robot Framework with Git?

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.


28. How do you handle dynamic elements in web automation?

Answer:

  • Use XPath or CSS selectors that can handle dynamic IDs.

  • Example:

Click Element  xpath=//button[contains(text(),'Submit')]

29. What is RPA in Robot Framework?

Answer:

  • Robot Framework can be used for Robotic Process Automation, automating repetitive tasks such as Excel manipulation, web forms, email handling, and file operations.


30. Can Robot Framework be used for API testing?

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()}

31. What is the difference between 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

32. What is 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

33. What are different ways to run Robot Framework tests?

Answer:

  1. Command line:

robot testfile.robot
  1. Using tags:

robot --include smoke testfile.robot
  1. Through Python script:

from robot import run
run('testfile.robot')
  1. Through CI/CD tools: Jenkins, GitHub Actions.


34. How do you pass data to test cases dynamically?

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

35. What is the difference between 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

36. How do you handle alerts/pop-ups in Robot Framework?

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

37. How do you perform database testing in Robot Framework?

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

38. What is the difference between 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.


39. How do you read data from Excel in Robot Framework?

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

40. How do you handle dynamic waits in Robot Framework?

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.


41. How do you debug tests in Robot Framework?

Answer:

  • Use Log to print variable values.

  • Use BuiltIn.Breakpoint to pause execution and inspect.

  • Check log.html for detailed step-by-step execution.


42. What is the difference between 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

43. How do you capture screenshots on test failure?

Answer:

  • SeleniumLibrary automatically captures screenshots using Capture Page Screenshot.

  • Can be done in Test Teardown:

*** Test Cases ***
Test With Screenshot
    [Teardown]  Capture Page Screenshot

44. How do you handle multiple browsers in Robot Framework?

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

45. How do you perform API testing in Robot Framework?

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()}

46. How do you handle loops and conditions together?

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

47. How do you handle multiple environments in Robot Framework?

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/

48. How do you run a subset of tests using tags?

Answer:

robot --include smoke tests/
robot --exclude regression tests/

49. How do you extend Robot Framework with custom Python libraries?

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}

50. Common mistakes freshers make in Robot Framework interviews:

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.

 

Experienced Interview Questions

 

1. How is Robot Framework used in automation frameworks for real-time projects?

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.


2. Explain a hybrid framework in Robot Framework.

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.


3. How do you manage environment-specific variables in Robot Framework?

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.


4. How do you implement modular reusable keywords?

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

5. How do you handle dynamic elements in web automation?

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.


6. How do you integrate Robot Framework with CI/CD pipelines (Jenkins/GitHub Actions)?

Answer:

  1. Configure Robot Framework environment in Jenkins.

  2. Create Jenkins job → Add Execute shell/build step:

robot -d results tests/
  1. Install Robot Framework plugin to display report.html and log.html in Jenkins.

  2. Use post-build actions for notifications on failures.

  3. For GitHub Actions, use robotframework/robotframework Docker image in workflow YAML.


7. How do you manage parallel execution in Robot Framework?

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.


8. How do you perform API testing using Robot Framework?

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.


9. How do you handle database testing with Robot Framework?

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).


10. How do you implement data-driven testing in Robot Framework?

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

11. How do you handle exception handling in Robot Framework?

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

12. How do you handle file uploads and downloads?

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.


13. How do you implement logging and reporting best practices?

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.


14. How do you handle cross-browser testing?

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.


15. How do you implement custom Python libraries?

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}

16. How do you handle dynamic web tables?

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}

17. How do you implement RPA (Robotic Process Automation) with Robot Framework?

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


18. How do you manage test suite scalability in large projects?

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.


19. How do you implement continuous testing?

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


20. How do you optimize test execution time?

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


21. How do you handle multiple test environments in a single Robot Framework project?

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.


22. How do you implement keyword hierarchies for reusability?

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.


23. How do you integrate Robot Framework with REST APIs and DB for end-to-end testing?

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

24. How do you implement cross-browser and cross-platform testing?

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.


25. How do you implement data-driven API testing?

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

26. How do you handle dynamic waits and AJAX elements?

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.


27. How do you implement parallel execution with dependencies?

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


28. How do you handle large-scale test suites efficiently?

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


29. How do you handle sensitive data like passwords?

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


30. How do you implement logging and reporting best practices?

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


31. How do you handle synchronous and asynchronous operations?

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

32. How do you perform file and folder operations in Robot Framework?

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


33. How do you implement custom listeners in Robot Framework?

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/

34. How do you integrate Robot Framework with version control?

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


35. How do you handle test data management in large projects?

Answer:

  • Use external data sources: Excel, CSV, JSON, databases

  • Separate test logic from test data

  • Parameterize using Test Template and FOR loops


36. How do you implement custom keywords for non-UI automation?

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


37. How do you handle email notifications for test results?

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

38. How do you handle complex XPath/CSS locators in dynamic applications?

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}

39. How do you implement retry mechanism for flaky tests?

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


40. How do you integrate Robot Framework with Docker?

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