Skip to main content

Interactive web dialogs and custom Jinja2 forms for Robot Framework tests

Project description

RobotFramework - WebDialogs

WebDialogs is a Robot Framework library that allows you to run interactive dialogs in a web browser instead of the console or native GUI windows. It is designed to be compatible with the official Robot Framework Dialog library, making migration or coexistence seamless. Additionally, it supports creating more complex dialogs using HTML templates written with Jinja2, providing flexible and customizable interfaces. Features

  • Full support for dialogs compatible with Robot Framework's built-in Dialog library.
  • Simple, responsive web interaction using Bootstrap.
  • Embedded Flask web server, running alongside your tests.
  • Support for dialogs with buttons, inputs, and selections.
  • Ability to create custom HTML dialog templates with Jinja2.
  • Ability to pass Robot Framework data into custom templates.
  • Architecture based on Robot Framework client + Flask server for maximum flexibility.

ezgif-3341d1f635d951

Installation

pip install robotframework-webdialogs

Basic Usage

*** Settings ***
Library    WebDialogs

*** Tasks ***
Pause Execution
    Pause Execution    Connect the cables and press continue

The test will pause and open a dialog in the browser. To view it, open:

http://localhost:5000

Examples

Dialogs.Get Value From User

Get User Personal Information
    [Documentation]    Collects basic personal information through dialogs
    ${name}=    Dialogs.Get Value From User    Please enter your first name:
    Log To Console    \nUser provided name: ${name}

Dialogs.Get Selection From User

Select Gender From Options
    [Documentation]    Demonstrates single-selection dialog
    @{genders}=    Create List    Male    Female    Non-binary    Prefer not to say
    ${gender}=    Dialogs.Get Selection From User    
    ...    Please select your gender:    
    ...    options=${genders}
    Log To Console   \nSelected gender: ${gender}

Dialogs.Get Selections From User

Select Multiple Favorite Animals
    [Documentation]    Demonstrates multi-selection dialog with validation
    @{animals}=    Create List    Cats    Dogs    Horses    Birds    Fish
    ${selected_animals}=    Dialogs.Get Selections From User    
    ...    Select your favorite animals:    
    ...    options=${animals}
    
    Should Not Be Empty    ${selected_animals}    No animals selected
    Log To Console    \nFavorite animals: ${selected_animals}

Dialogs.Pause Execution

Pause Execution
    [Documentation]    Pauses test execution and opens a dialog
    Dialogs.Pause Execution    Connect the cables and press continue

Dialogs.Execute Manual Step

Manual Verification Step
    [Documentation]    Requires manual user verification
    ${verification_result}=    Dialogs.Execute Manual Step    
    ...    Please verify the device connection    
    Log To Console    \nVerification result: ${verification_result}

Dialogs.Execute Custom Step

Process Complex Form Submission
    [Documentation]    Tests custom form handling
    ${form_response}=    Dialogs.Execute Custom Step    
    ...    step=complexform    
    
    Should Contain    ${form_response}    input    Form submission failed
    Log To Console    \nForm processing result: ${form_response}

You can also pass data into the custom template:

Process Data-Driven Complex Form Submission
    [Documentation]    Tests custom form handling with data passed to the template
    VAR    &{testdata}
    ...    data1=value1
    ...    data2=${EMPTY}

    ${form_response}=    Dialogs.Execute Custom Step
    ...    step=data_driven_form
    ...    data=${testdata}

    Should Contain    ${form_response}    data1    Form submission failed
    Should Contain    ${form_response}    data2    Form submission failed
    Log To Console    \nData-driven form processing result: ${form_response}

Advanced Usage: Custom HTML Dialogs

You can create HTML dialog templates with Jinja2 for complex interfaces.

Use keyword Execute Custom Step step=complexform to open the custom dialog. Create the dialog template in a file named complexform.html in the templates/ folder in your root project.

When using Execute Custom Step with the optional data argument, the values are available in the Jinja2 template through the data variable:

{% for key, value in data.items() %}
  <label>{{ key }}</label>
  <input name="{{ key }}" value="{{ value }}">
{% endfor %}

The submitted form values are returned to Robot Framework as the custom step response.

Complete Example

A fully working example is available in the example folder of the repository, which includes:

  • Robot Framework test code
  • Flask server code
  • HTML templates
  • Setup and run instructions

Architecture

  • Robot Framework Client: sends dialog requests to the server.
  • Flask Server: exposes a web interface where users respond to dialogs.
  • Asynchronous communication with blocking waits on the Robot side until user response.

Requirements

  • Python 3.9+
  • Robot Framework 7.0+
  • Modern web browser (Chrome, Firefox, Edge)

Roadmap

  • Add test to the library.
  • Documentation on creating and using custom Jinja2 templates.
  • CI/CD integration examples.
  • Improved error handling and support for concurrent sessions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotframework_webdialogs-0.2.0.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robotframework_webdialogs-0.2.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file robotframework_webdialogs-0.2.0.tar.gz.

File metadata

File hashes

Hashes for robotframework_webdialogs-0.2.0.tar.gz
Algorithm Hash digest
SHA256 29d1b0dcca78b21adeb0bb55f70f26be605c78e75a08917b27bfd07473107afc
MD5 ad9fffa5fb545bc9cf0a9a3b6635336b
BLAKE2b-256 478db126bc4f214d2dc08abc1b8bb6d55563a6d725003b3fe0db34d11859e907

See more details on using hashes here.

File details

Details for the file robotframework_webdialogs-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for robotframework_webdialogs-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18573dc4dfa31f8a335059ccc33199773e49616031097eabdea9e55687b57d6a
MD5 924411f2b470516c7b502d0606892769
BLAKE2b-256 0e97951d2379ea1d74f284ecbb5ea1f9cfd1300620c2265751cff744c5415bb2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page