Python API

Assistant

class RPA.Assistant.Assistant

The Assistant library provides a way to display information to a user and request input while a robot is running. It allows building processes that require human interaction. Also it offers capabilities of running other robots inside the current one and determine what to display to the user based on his previous responses.

It is not included in the rpaframework package, so in order to use it you have to add rpaframework-assistant with the desired version in your conda.yaml file

Some examples of use-cases could be the following:

  • Displaying generated files after an execution is finished

  • Displaying dynamic and user-friendly error messages

  • Requesting passwords or other personal information

  • Running Keywords based on user’s actions

  • Displaying dynamic content based on user’s actions

  • Automating based on files created by the user

Workflow

The library is used to create dialogs, i.e. windows, that can be composed on-the-fly based on the current state of the execution.

The content of the dialog is defined by calling relevant keywords such as Add text or Add file input. When the dialog is opened the content is generated based on the previous keywords.

Depending on the way the dialog is started, the execution will either block or continue while the dialog is open. During this time the user can freely edit any possible input fields or handle other tasks.

After the user has successfully submitted the dialog, any possible entered input will be returned as a result. The user also has the option to abort by closing the dialog window forcefully.

Results

Each input field has a required name argument that controls what the value will be called in the result object. Each input name should be unique, and must not be called submit as that is reserved for the submit button value.

A result object is a Robot Framework DotDict, where each key is the name of the input field and the value is what the user entered. The data type of each field depends on the input. For instance, a text input will have a string, a checkbox will have a boolean, and a file input will have a list of paths.

If the user closed the window before submitting or there was an internal error, the results object returned by Run Dialog or Ask User won’t have a “submit” key.

Layouting

By default elements are added to the assistant dialog from top to bottom, with a bit of margin around each element to add spaciousness. This margin is added as a Container you can manually use Open Container to override the default container. You can use it to set smaller margins.

You can combine layouting elements with each other. Layouting elements need to be closed with the corresponding Close keyword. (So Open Row and then Close Row.)

Open Row can be used to layout elements in the same row.

Open Column can be used to layout elements in columns.

Open Stack and multiple Open Container’s inside it can be used to set positions like Center, Topleft, BottomRight, or coordinate tuples likes (0, 0), (100, 100) and such.

Open Container can bse used for absolute positioning inside a Stack, or anywhere for setting background color or margins and paddings.

Open Navbar can be used to make a navigation bar that will stay at the top of the dialog. Its contents won’t be cleared when.

Examples

*** Keywords ***
Success dialog
    Add icon      Success
    Add heading   Your orders have been processed
    Add files     *.txt
    Run dialog    title=Success

Failure dialog
    Add icon      Failure
    Add heading   There was an error
    Add text      The assistant failed to login to the Enterprise portal
    Add link      https://robocorp.com/docs    label=Troubleshooting guide
    Run dialog    title=Failure

Large dialog
    Add heading    A real chonker   size=large
    Add image      fat-cat.jpeg
    Run dialog     title=Large    height=1024    width=1024

Confirmation dialog
    Add icon      Warning
    Add heading   Delete user ${username}?
    Add submit buttons    buttons=No,Yes    default=Yes
    ${result}=    Run dialog
    IF   $result.submit == "Yes"
        Delete user    ${username}
    END

Input form dialog
    Add heading       Send feedback
    Add text input    email    label=E-mail address
    Add text input    message
    ...    label=Feedback
    ...    placeholder=Enter feedback here
    ...    maximum_rows=5
    ${result}=    Run dialog
    Send feedback message    ${result.email}  ${result.message}
def success_dialog():
    assistant = Assistant()
    assistant.add_icon("success")
    assistant.add_heading("Your orders have been processed")
    assistant.add_files("*.txt")
    assistant.run_dialog(title="Success")

def failure_dialog():
    assistant = Assistant()
    assistant.add_icon("failure")
    assistant.add_heading("There was an error")
    assistant.add_text("The assistant failed to login to the Enterprise portal")
    assistant.add_link("https://robocorp.com/docs", label="Troubleshooting guide")
    assistant.add_files("*.txt")
    assistant.run_dialog(title="Failure")

def large_dialog():
    assistant = Assistant()
    assistant.add_heading("A real chonker", size="large")
    assistant.add_image("fat-cat.jpeg")
    assistant.run_dialog(title="Large", height=1024, width=1024)

def confirmation_dialog():
    assistant = Assistant()
    assistant.add_icon("warning")
    assistant.add_heading("Delete user ${username}?")
    assistant.add_submit_buttons(buttons="No, Yes", default="Yes")
    result = assistant.run_dialog()
    if result.submit == "Yes":
        delete_user(username)

def input_from_dialog():
    assistant = Assistant()
    assistant.add_heading("Send feedback")
    assistant.add_text_input("email", label="E-mail address")
    assistant.add_text_input("message", label="Feedback", placeholder="Enter feedback here", maximum_rows=5)
    assistant.add_submit_buttons("Submit", default="Submit")
    result = assistant.run_dialog()
    send_feedback_message(result.email, result.message)
ROBOT_AUTO_KEYWORDS = False
ROBOT_LIBRARY_DOC_FORMAT = 'REST'
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
add_button(label: str, function: Union[Callable, str], *args, location: VerticalLocation = VerticalLocation.Left, **kwargs) None

Create a button and execute the function as a callback when pressed.

Parameters
  • label – Text for the button

  • function – Python function or Robot Keyword name, that will get *args and **kwargs passed into it

Example:

*** Keywords ***
First View
    Add Heading  Here is the first view of the app
    Add Button  Change View  Second View

Second View
    Add Heading  Let's build an infinite loop
    Add Button  Change View  First View
def first_view():
    assistant = Assistant()
    assistant.add_heading("Here is the first view of the app")
    assistant.add_button("Change view", second_view)
    assistant.run_dialog()

def second_view():
    assistant = Assistant()
    assistant.add_heading("Let's build an infinite loop")
    assistant.add_button("Change view", first_view)
    assistant.run_dialog()
add_checkbox(name: str, label: str, default: bool = False) None

Add a checkbox element

Parameters
  • name – Name of result field

  • label – Label text for checkbox

  • default – Default checked state

Adds a checkbox that indicates a true or false value. The selection will be available in the name field of the result, and the label text will be shown next to the checkbox.

The boolean default value will define the initial checked state of the element.

Example:

*** Keywords ***
Select checkboxes
    Add heading     Enable features
    Add checkbox    name=vault        label=Enable vault       default=True
    Add checkbox    name=triggers     label=Enable triggers    default=False
    Add checkbox    name=assistants   label=Enable assistants  default=True
    ${result}=      Run dialog
    IF    $result.vault
        Enable vault
    END
def select_checkboxes():
    assistant = Assistant()
    assistant.add_heading("Enable features")
    assistant.add_checkbox(name="vault", label="Enable vault", default=True)
    assistant.add_checkbox(name="triggers", label="Enable triggers", default=False)
    assistant.add_checkbox(name="assistants", label="Enable assistants", default=True)
    result = assistant.run_dialog()
    if(result.vault):
        enable_vault()
add_date_input(name: str, default: Optional[Union[date, str]] = None, label: Optional[str] = None) None

Add a date input element.

Parameters
  • name – Name of the result field

  • default – The default set date

  • label – Label for the date input field

Displays a date input. The selection the user makes will be available as a date object in the name field of the result. The default argument can be a pre-set date as object or string in “YYYY-MM-DD” format, otherwise the current date is used.

Example:

*** Keywords ***
Select birthdate
    Add heading       Enter your birthdate
    Add Date Input    birthdate    default=1993-04-26
    ${result} =       Run dialog
    Log To Console    User birthdate year should be: ${result.birthdate.year}
def select_birthdate():
    assistant = Assistant()
    assistant.add_heading("Enter your birthdate")
    assistant.add_date_input("birthdate", default="1993-04-26")
    result = assistant.run_dialog()
    print("User birthdate year should be: ", result.birthdate.year)
add_drop_down(name: str, options: Union[List[str], str], default: Optional[str] = None, label: Optional[str] = None) None

Add a drop-down element

Parameters
  • name – Name of result field

  • options – List of drop-down options

  • default – The default selection

  • label – Label for input field

Creates a drop-down menu with the given options. The selection the user makes will be available in the name field of the result.

The default argument can be one of the defined options, and the dialog automatically selects that option for the input.

A custom label text can also be added.

Example:

*** Keywords ***
Select user type from drop down
    Add heading     Select user type
    Add drop-down
    ...    name=user_type
    ...    options=Admin,Maintainer,Operator
    ...    default=Operator
    ...    label=User type
    ${result}=      Run dialog
    Log    User type should be: ${result.user_type}
def select_user_type_from_drop_down():
    assistant = Assistant()
    assistant.add_heading("Select user type")
    assistant.add_drop_down(
        name="user_type",
        options="Admin,Maintainer,Operator",
        default="Operator",
        label="User type"
    )
    result = assistant.run_dialog()
    print("User type should be: ", result.user_type)
add_file(path: str, label: Optional[str] = None) None

Add a file element, which links to a local file

Parameters
  • path – The path to the file

  • label – A custom label text for the file

Adds a button which opens a local file with the corresponding default application. Can be used for instance to display generated files from the robot to the end-user.

Optionally a custom label can be given for the button text. By default uses the filename of the linked file.

Example:

*** Keywords ***
Open file button
    ${path}=   Generate order files
    Add heading    Current orders
    Add file    ${path}    label=Current
    Run dialog
def open_file_button():
    path = generate_order_files()
    assistant = Assistant()
    assistant.add_heading("Current orders")
    assistant.add_file(path, label="Current")
    assistant.run_dialog()
add_file_input(name: str, label: Optional[str] = None, source: Optional[str] = None, file_type: Optional[str] = None, multiple: bool = False) None

Add a file input element

Parameters
  • name – Name of result field

  • label – Label for input field

  • source – Default source directory

  • file_type – Accepted file types

  • multiple – Allow selecting multiple files

Adds a native file selection dialog for inputting one or more files. The list of selected files will be available in the name field of the result.

By default opens up in the user’s home directory, but it can be set to a custom path with the source argument.

The argument file_type restricts the possible file extensions that the user can select. The format of the argument is as follows: pdf,png,svg. For instance, an argument to limit options to Excel files could be: xls,xlsx.

To allow selecting more than one file, the multiple argument can be enabled.

Example:

*** Keywords ***
Multiple file selections
    # This can be any one file
    Add file input    name=anything

    # This can be multiple files
    Add file input    name=multiple  multiple=True

    # This opens the select dialog to a custom folder
    Add file input    name=src       source=C:\Temp\Output\

    # This restricts files to certain types
    Add file input    name=types     file_type=pdf

    # Every file input result is a list of paths
    ${result}=    Run dialog
    FOR    ${path}    IN    @{result.multiple}
        Log    Selected file: ${path}
    END
def multiple_file_selections():
    assistant = Assistant()
    # This can be any one file
    assistant.add_file_input(name="anything")

    # This can be multiple files
    assistant.add_file_input(name="multiple", multiple=True)

    # This opens the select dialog to a custom folder
    assistant.add_file_input(name="src", source="C:\Temp\Output")

    # This restricts files to certain types
    assistant.add_file_input(name="types", file_type="pdf")

    # Every file input result is a list of paths
    result = assistant.run_dialog()
    for path in result.multiple:
        print("Selected file: ", path)
add_files(pattern: str) None

Add multiple file elements according to the given file pattern

Parameters

pattern – File matching pattern

See the keyword Add file for information about the inserted element itself.

The keyword uses Unix-style glob patterns for finding matching files, and the supported pattern expressions are as follow:

Pattern

Meaning

*

Match everything

?

Match any single character

[seq]

Match any character in seq

[!seq]

Match any character not in seq

**

Match all files, directories, and subdirectories

If a filename has any of these special characters, they can be escaped by wrapping them with square brackets.

Example:

*** Keywords ***
Open multiple files buttons
    # Add all excel files
    Add files    *.xlsx

    # Add all log files in any subdirectory
    Add files    **/*.log

    # Add all PDFs between order0 and order9
    Add files    order[0-9].pdf
def open_multiple_files_buttons():
    assistant = Assistant()
    # Add all excel files
    assistant.add_file("*.xlsx")
    # Add all log files in any subdirectory
    assistant.add_file("**/*.log")
    # Add all PDFs between order0 and order9
    assistant.add_file("order[0-9].pdf")
    assistant.run_dialog()
add_flet_icon(icon: str, color: Optional[str] = None, size: Optional[int] = 24)

Add an icon from a large gallery of icons.

Parameters

Example:

*** Keywords ***
Add custom icon
    Add Heading    Check icon
    Add Flet Icon  icon_name=check_circle_rounded  color=FF00FF  size=48
    Run Dialog
def add_custom_icon()
    assistant = Assistant()
    assistant.add_heading("Check icon")
    assistant.add_flet_icon(icon="check_circle_rounded", color="FF00FF", size="48")
    assistant.run_dialog()
add_heading(heading: str, size: Size = Size.Medium) None

Add a centered heading text element

Parameters
  • heading – The text content for the heading

  • size – The size of the heading

Supported size values are Small, Medium, and Large. By default uses the value Medium.

Example:

*** Keywords ***
Add dialog heading
    Add heading     User information  size=Large
    Add heading     Location          size=Small
    Add text input  address           label=User address
    Run dialog
def add_dialog_heading():
    assistant = Assistant()
    assistant.add_heading("User information", size="large")
    assistant.add_heading("Location", size="small")
    assistant.add_text_input("address", label="User address")
    assistant.run_dialog()
add_hidden_input(name: str, value: str) None

Add a hidden input element

Parameters
  • name – Name of result feild

  • value – Value for input

Adds a special hidden result field that is not visible to the user and always contains the given static value.

Can be used to keep user input together with already known values such as user IDs, or to ensure that dialogs with differing elements all have the same fields in results.

Example:

*** Keywords ***
Get user information
    Add hidden input   user_id   ${USER_ID}
    Add text input     username
    ${result}=         Run dialog
    Enter user information    ${result.user_id}    ${result.username}
def get_user_information():
    assistant = Assistant()
    user_id = "Your user value"
    assistant.add_hidden_input("user_id", user_id)
    assistant.add_text_input("username")
    result = assistant.run_dialog()
    enter_user_information(result.user_id, result.username)
add_icon(variant: Icon, size: int = 48) None

Add an icon element from RPA.Assistant’s short icon list.

Parameters
  • variant – The icon type

  • size – The size of the icon

Adds an icon which can be used to indicate status or the type of dialog being presented.

The currently supported icon types are:

Name

Description

Success

A green check mark

Warning

An orange warning triangle

Failure

A red cross or X mark

The size of the icon can also be changed, to a given height/width of pixels.

Example:

*** Keywords ***
Confirmation dialog
    Add icon              Warning    size=64
    Add heading           Do you want to delete this order?
    Add submit buttons    buttons=No,Yes
    ${result}=    Run dialog
def confirmation_dialog():
    assistant = Assistant()
    assistant.add_icon("warning", size="64")
    assistant.add_heading("Do you want to delete this order?")
    assistant.add_submit_buttons(buttons="No, Yes")
    result = assistant.run_dialog()
add_image(url_or_path: str, width: Optional[int] = None, height: Optional[int] = None) None

Add an image element, from a local file or remote URL

Parameters
  • url_or_path – The location of the image

  • width – The static width of the image, in pixels

  • height – The static height of the image, in pixels

Adds an inline image to the dialog, which can either point to a local file path on the executing machine or to a remote URL. If it’s a local file path it has to be absolute path.

By default the image is resized to fit the width of the dialog window, but the width and/or height can be explicitly defined to a custom value. If only one of the dimensions is given, the other is automatically changed to maintain the correct aspect ratio.

Example:

*** Keywords ***
Display image
    Add image      C:\Users\me\company-logo.png
    Add heading    To start, please press the Continue button   size=Small
    Add submit buttons    Continue
    Run dialog

Add an external URL link element

Parameters
  • url – The URL for the link

  • label – A custom label text for the link

Adds a clickable link element, which opens the user’s default browser to the given url. Optionally a label can be given which is shown as the link text, instead of the raw URL.

Example:

*** Keywords ***
Display troubleshoot link
    Add heading    An error occurred
    Add text       See link for documentation
    Add link       https://robocorp.com/docs    label=Troubleshooting
    Run dialog
def add_troubleshoot_link():
    assistant = Assistant()
    assistant.add_heading("An error occurred")
    assistant.add_text("See link for documentation")
    assistant.add_link("https://robocorp.com/docs", label="Troubleshooting")
    assistant.run_dialog()
add_loading_bar(name: str, width: int = 16, bar_height: int = 16, color: Optional[str] = None, tooltip: Optional[str] = None, value: Optional[float] = None)

Add a loading bar.

Parameters
add_loading_spinner(name: str, width: int = 16, height: int = 16, stroke_width: int = 2, color: Optional[str] = None, tooltip: Optional[str] = None, value: Optional[float] = None)

Add a loading spinner.

Parameters
add_next_ui_button(label: str, function: Union[Callable, str])

Create a button that leads to the next UI page, calling the passed keyword or function, and passing current form results as first positional argument to it.

Parameters
  • label – Text for the button

  • function – Python function or Robot Keyword name, that will take form results as its first argument

Example:

*** Keywords ***
Retrieve User Data
    # Retrieves advanced data that needs to be displayed

Main Form
    Add Heading  Username input
    Add Text Input  name=username_1  placeholder=username
    Add Next Ui Button        Show customer details  Customer Details

Customer Details
    [Arguments]  ${form}
    ${user_data}=  Retrieve User Data  ${form}[username_1]
    Add Heading  Retrieved Data
    Add Text  ${user_data}[phone_number]
    Add Text  ${user_data}[address]
def main_form():
    assistant = Assistant()
    assistant.add_heading("Username input")
    assistant.add_text_input("username_1", placeholder="username")
    assistant.add_next_ui_button("Show customer details", customer_details)
    assistant.run_dialog()

def customer_details(form):
    assistant = Assistant()
    user_data = retrieve_user_data(form.username_1)
    assistant.add_heading("Retrieved Data")
    assistant.add_text(user_data[phone_number])
    assistant.add_text(user_data[address])
    assistant.run_dialog()
add_password_input(name: str, label: Optional[str] = None, placeholder: Optional[str] = None) None

Add a password input element

Parameters
  • name – Name of result field

  • label – Label for field

  • placeholder – Placeholder text in input field

Adds a text field that hides the user’s input. The entered content will be available in the name field of the result.

For customizing the look of the input, the label text can be given to add a descriptive label and the placholder text can be given to act as an example of the input value.

Example:

*** Keywords ***
Change password
    Add heading    Change password
    Add text input        username    label=Current username
    Add password input    password    label=New password
    Add submit buttons    buttons=Submit
    ${result}=    Run dialog
    Change user password    ${result.username}  ${result.password}
def change_password():
    assistant = Assistant()
    assistant.add_heading("Change password")
    assistant.add_text_input("username", label="Current username")
    assistant.add_password_input("password", label="New password")
    assistant.add_submit_buttons(buttons="Submit")
    result = assistant.run_dialog()
    change_user_password(result.username, result.password)
add_radio_buttons(name: str, options: Union[List[str], str], default: Optional[str] = None, label: Optional[str] = None) None

Add radio button elements

Parameters
  • name – Name of result field

  • options – List of drop-down options

  • default – The default selection

  • label – Label for input field

Creates a set of radio buttons with the given options. The selection the user makes will be available in the name field of the result.

The default argument can be one of the defined options, and the dialog automatically selects that option for the input.

A custom label text can also be added.

Example:

*** Keywords ***
Select user type from radio buttons
    Add heading     Select user type
    Add radio buttons
    ...    name=user_type
    ...    options=Admin,Maintainer,Operator
    ...    default=Operator
    ...    label=User type
    ${result}=      Run dialog
    Log    User type should be: ${result.user_type}
def select_user_type_from_radio_buttons():
    assistant = Assistant()
    assistant.add_heading("Select user type")
    assistant.add_radio_buttons(
        name="user_type",
        options="Admin,Maintainer,Operator",
        default="Operator",
        label="User type"
    )
    result = assistant.run_dialog()
    print("User type should be: ", result.user_type)
add_slider(name: str, slider_min: Union[int, float] = 0, slider_max: Union[int, float] = 100, thumb_text='{value}', steps: Optional[int] = None, default: Optional[Union[int, float]] = None, decimals: Optional[int] = 1)

Add a slider input.

Parameters
  • name – Name of result field

  • slider_min – Minimum value of the slider

  • slider_max – Maximum value of the slider

  • thumb_label – Text to display when the slider is being slided. Use the placeholder {value} for the number. (thumb text {value%} will display values: 0%, 100%)

  • steps – Amount of steps for the slider. If None, the slider will be continuous. For integer output, specify a steps value where all the steps will be integers, or implement rounding when retrieving the result.

  • default – Default value for the slider. Must be between min and max.

  • decimals – How many decimals should the value have and show.

*** Keywords ***
Create Percentage Slider
    Add Text    Percentage slider
    Add Slider  name=percentage  slider_min=0  slider_max=100
                thumb_text={value}%  steps=100  round=1
def create_percentage_slider():
    assistant = Assistant()
    assistant.add_text("Percentage slider")
    assistant.add_slider(
        name="percentage",
        slider_min=0,
        slider_max=100,
        thumb_text="{value}%",
        steps=100,
        decimals=1
    )
    assistant.run_dialog()
add_submit_buttons(buttons: Union[List[str], str], default: Optional[str] = None) None

Add custom submit buttons

Parameters
  • buttons – Submit button options

  • default – The primary button

The result field will always be called submit and will contain the pressed button text as a value.

If one of the custom options should be the preferred option, the default argument controls which one is highlighted with an accent color.

Example:

*** Keywords ***
Delete user warning
    Add icon      Warning
    Add heading   Delete user ${username}?
    Add submit buttons    buttons=No,Yes    default=Yes
    ${result}=    Run dialog
    IF   $result.submit == "Yes"
        Delete user    ${username}
    END
def delete_user_warning():
    assistant = Assistant()
    username = "user_01"
    assistant.add_icon("warning")
    assistant.add_heading(f"Delete user {username}?")
    assistant.add_submit_buttons(buttons="No, Yes", default="Yes")
    result = assistant.run_dialog()
    if result.submit == "Yes":
        delete_user(username)
add_text(text: str, size: Size = Size.Medium) None

Add a text paragraph element, for larger bodies of text

Parameters
  • text – The text content for the paragraph

  • size – The size of the text

Supported size values are Small, Medium, and Large. By default uses the value Medium.

Example:

*** Keywords ***
Show error dialog
    Add heading   An error occurred
    Add text      There was an error while requesting user information
    Add text      ${error}   size=Small
    Run dialog
def show_error_dialog():
    error = "Your error message"
    assistant = Assistant()
    assistant.add_heading("An error occurred")
    assistant.add_text("There was an error while requesting user information")
    assistant.add_text(f"{error}", size="small")
    assistant.run_dialog()
add_text_input(name: str, label: Optional[str] = None, placeholder: Optional[str] = None, validation: Optional[Union[Callable, str]] = None, default: Optional[str] = None, required: bool = False, minimum_rows: Optional[int] = None, maximum_rows: Optional[int] = None) None

Add a text input element

Parameters
  • name – Name of result field

  • label – Label for field

  • placeholder – Placeholder text in input field

  • validation – Validation function for the input field

  • default – Default value if the field wasn’t completed

  • required – If true, will display an error if not completed

  • minimum_rows – Minimum number of rows to display for the input field

  • maximum_rows – Maximum number of rows to display for the input field, the input content can be longer but a scrollbar will appear

Adds a text field that can be filled by the user. The entered content will be available in the name field of the result.

For customizing the look of the input, the label text can be given to add a descriptive label and the placholder text can be given to act as an example of the input value.

The default value will be assigned to the input field if the user doesn’t complete it. If provided, the placeholder won’t be shown. This is None by default. Also, if a default value is provided and the user deletes it, None will be the corresponding value in the results dictionary.

Example:

*** Keywords ***
Send feedback
    Add heading    Send feedback
    Add text input    email    label=E-mail address
    Add text input    message
    ...    label=Feedback
    ...    placeholder=Enter feedback here
    ${result}=    Run dialog
    Send feedback message    ${result.email}  ${result.message}

Validation example:

*** Keywords ***
Validate Email
    [Arguments]    ${email}
    # E-mail specification is complicated, this matches that the e-mail has
    # at least one character before and after the @ sign, and at least one
    # character after the dot.
    ${regex}=    Set Variable    ^.+@.+\..+
    ${valid}=    Run Keyword And Return Status    Should Match Regexp  ${email}  ${regex}
    IF  not $valid
        RETURN  Invalid email address
    END

Open Dialog
    Add heading    Send feedback
    Add text input    email
    ...    label=Email
    ...    validation=Validate Email
    ${result}=    Run dialog
    Log  ${result.email}
import re
def validate_email(email):
    # E-mail specification is complicated, this matches that the e-mail has
    # at least one character before and after the @ sign, and at least one
    # character after the dot.
    regex = r"^.+@.+\..+"
    valid = re.match(regex, email)
    if not valid:
        return "Invalid email address"

def open_dialog():
    assistant.add_heading("Send feedback")
    assistant.add_text_input("email", label="Email", validation=validate_email)
    result = run_dialog()
    print(result.email)
ask_user(timeout: int = 180, **options: Any) Dict[str, Any]

Same as Run Dialog it will create a dialog from all the defined elements and block until the user has handled it. It will also add by default a submit and close buttons.

Parameters
  • timeout – Time to wait for dialog to complete, in seconds

  • options – Options for the dialog

Returns a result object with all input values.

For more information about possible options for opening the dialog, see the documentation for the keyword Run Dialog.

Example:

*** Keywords ***
Ask user dialog
    Add heading     Please enter your username
    Add text input  name=username
    ${result}=      Ask User
    Log    The username is: ${result.username}
def ask_user_dialog():
    assistant = Assistant()
    assistant.add_heading("Please enter your username")
    assistant.add_text_input("username")
    result = assistant.ask_user()
    print("The username is: ", result.username)
clear_dialog() None

Clear dialog and results while it is running.

close_column()

Closes previously opened Column.

Raises LayoutError if called with no Column open, or if another layout element was opened more recently than a Column.

close_container()

Close previously opened container.

Raises LayoutError if called with no Row open, or if another layout element was opened more recently than a row.

close_navbar()

Close previously opened navbar.

Raises LayoutError if called with no Row open, or if another layout element was opened more recently than a row.

close_row()

Close previously opened row.

Raises LayoutError if called with no Row open, or if another layout element was opened more recently than a row.

close_stack()

Close previously opened Stack.

Raises LayoutError if called with no Stack open, or if another layout element was opened more recently than a Stack.

open_column()

Open a Column layout container. Following Add <element> calls will add items into that Column until Close Column is called.

*** Keywords ***
Double Column Layout
    Open Row
    Open Column
    Add Text      First item in the first column
    Add Text      Second item on the first column
    Close Column
    Open Column
    Add Text      First item on the second column
    Close Column
    Close Row
def double_column_layout():
    assistant = Assistant()
    assistant.open_row()
    assistant.open_column()
    assistant.add_text("First item in the first column")
    assistant.add_text("Second item on the first column")
    assistant.close_column()

    assistant.open_column()
    assistant.add_text("First item on the second column")
    assistant.close_column()
    assistant.close_row()

    assistant.run_dialog()
open_container(margin: Optional[int] = 5, padding: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None, background_color: Optional[str] = None, location: Optional[Union[Location, Tuple[int, int]]] = None)

Open a single element container. The following Add <element> calls adds an element inside the container. Can be used for styling elements.

Parameters
  • margin – How much margin to add around the container. RPA.Assistant adds by default a container of margin 5 around all elements, to have a smaller margin use containers with smaller margin value for elements.

  • padding – How much padding to add around the content of the container.

  • width – Width of the container.

  • height – Height of the container.

  • bgcolor – Background color for the container. Default depends on icon. Allowed values are colors from [https://github.com/flet-dev/flet/blob/035b00104f782498d084c2fd7ee96132a542ab7f/sdk/python/packages/flet-core/src/flet_core/colors.py#L37|Flet Documentation] (in the format black12, red500) or ARGB/RGB (#FFXXYYZZ or #XXYYZZ).XXYYZZ

  • location

    Where to place the container (A Location value or tuple of ints). Only works inside a Stack layout element.

    To use any Center___ or ___Center locations you must define width and height to the element.

*** Keywords ***
Padded Element With Background
    Open Container  padding=20  background_color=blue500
    Add Text        sample text
    Close Container
def padded_element_with_background():
    assistant = Assistant()
    assistant.open_container(padding=20, background_color="blue500")
    assistant.add_text("Sample text")
    assistant.close_container()
    assistant.run_dialog()
open_navbar(title: Optional[str] = None)

Create a Navigation Bar. Following Add <element> calls will add items into the Navbar until Close Navbar is called.

Navbar doesn’t clear when Clear Dialog is called.

Only one Navbar can be initialized at a time. Trying to make a second one will raise a LayoutError.

*** Keywords ***
    Go To Start Menu
        Add Heading  Start menu
        Add Text  Start menu content

    Assistant Navbar
        Open Navbar  title=Assistant
        Add Button   menu  Go To Start Menu
        Close Navbar
def go_to_start_menu():
    assistant = Assistant()
    assistant.add_heading("Start menu")
    assistant.add_text("Start menu content")
    assistant.run_dialog()

def assistant_navbar():
    assistant = Assistant()
    assistant.open_navbar(title="Assistant")
    assistant.add_button("menu", go_to_start_menu)
    assistant.close_navbar()
    assistant.run_dialog()
open_row()

Open a row layout container. Following Add <element> calls will add items into that row until Close Row is called.

*** Keywords ***
Side By Side Elements
    Open Row
    Add Text  First item on the row
    Add Text  Second item on the row
    Close Row
def side_by_side_elements():
    assistant = Assistant()
    assistant.open_row()
    assistant.add_text("First item on the row")
    assistant.add_text("Second item on the row")
    assistant.close_row()
    assistant.run_dialog()
open_stack(width: Optional[int] = None, height: Optional[int] = None)

Create a “Stack” layout element. Stack can be used to position elements absolutely and to have overlapping elements in your layout. Use Container’s top and left arguments to position the elements in a stack.

*** Keywords ***
Absolutely Positioned Elements
    # Positioning containers with relative location values requires
    # absolute size for the Stack
    Open Stack  height=360  width=360

    Open Container  width=64  height=64  location=Center
    Add Text  center
    Close Container

    Open Container  width=64  height=64  location=TopRight
    Add Text  top right
    Close Container

    Open Container  width=64  height=64  location=BottomRight
    Add Text  bottom right
    Close Container

    Close Stack
def absolutely_positioned_elements():
    # Positioning containers with relative location values requires
    # absolute size for the Stack
    assistant = Assistant()
    assistant.open_stack(height=360, width=360)

    assistant.open_container(width=64, height=64, location=Center)
    assistant.add_text("center")
    assistant.close_container()

    assistant.open_container(width=64, height=64, location=TopRight)
    assistant.add_text("top right")
    assistant.close_container()

    assistant.open_container(width=64, height=64, location=BottomRight)
    assistant.add_text("bottom right")
    assistant.close_container()

    assistant.close_stack()
    assistant.run_dialog()
refresh_dialog()

Can be used to update UI elements when adding elements while dialog is running

run_dialog(timeout: int = 180, title: str = 'Assistant', height: Union[int, typing_extensions.Literal[AUTO]] = 'AUTO', width: int = 480, on_top: bool = False, location: Optional[Union[WindowLocation, Tuple[int, int]]] = None) Dict[str, Any]

Create a dialog from all the defined elements and block until the user has handled it.

Parameters
  • timeout – Time to wait for dialog to complete, in seconds

  • title – Title of dialog

  • height – Height of dialog (in pixels or ‘AUTO’)

  • width – Width of dialog (in pixels)

  • on_top – Show dialog always on top of other windows

  • location – Where to place the dialog (options are Center, TopLeft, or a tuple of ints)

If the location argument is None it will let the operating system place the window.

Returns a result object with all input values.

When the dialog closes elements are cleared.

Example:

*** Keywords ***
Open dialog
    Add heading     Please enter your username
    Add text input  name=username
    ${result}=      Run dialog
    Log    The username is: ${result.username}
def open_dialog():
    assistant = Assistant()
    assistant.add_heading("Please enter your username")
    assistant.add_text_input("username")
    result = assistant.run_dialog()
    print("The username is: ", result.username)
set_title(title: str)

Set dialog title when it is running.