Skip to content

[Feature] Add optional parameter 'data' to execute_custom_step keyword#1

Open
osedlbauer wants to merge 1 commit into
Ymil:mainfrom
osedlbauer:feature/execute-custom-step-data-obj
Open

[Feature] Add optional parameter 'data' to execute_custom_step keyword#1
osedlbauer wants to merge 1 commit into
Ymil:mainfrom
osedlbauer:feature/execute-custom-step-data-obj

Conversation

@osedlbauer
Copy link
Copy Markdown

I stumbled across this project and think it is really great. It works like a charm!

This PR adds an optional parameter 'data' to the 'Execute Custom Step' keyword.
The object is passed through to the Jinja2 template, allowing custom templates to handle more complex and dynamic dialog windows.

This is a small example of the use case this PR solves:

templates/complexform.html

{% extends "dialogs/layout.html" %}
{% block dialog_content %}

<h5>Enter Data</h5>

<form method="POST" action="/dialog/submit">

  {% for key, value in data.items() %}
  <div class="mb-3">
    <label class="form-label">{{ key }}</label>
    <input
      type="text"
      class="form-control"
      name="{{ key }}"
      value="{{ value }}">
  </div>
  {% endfor %}

  <button type="submit" class="btn btn-primary">Submit</button>
</form>
{% endblock %}

test.robot

*** Settings ***
Library    WebDialogs


*** Test Cases ***
Test Complex Form With Data
    VAR     &{testdata}
    ...    data1=value1
    ...    data2=${EMPTY}

    ${result}=    WebDialogs.Execute Custom Step
    ...    step=complexform
    ...    data=${testdata}

    Log    result:${result}    console=true

Add an optional parameter 'data' to the 'Execute Custom Step' keyword.
This allows custom templates to access user-provided data.

Signed-off-by: Oliver Sedlbauer <os@dev.tdt.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant