Blackbriar
Blackbriar

Reputation: 507

Is there a way to directly pass a dictionary to a library

Using the Robot Framework, I know it is possible to pass a dictionary to a function like follows:

*** Settings ***
Library             Collections
Library             SomeLibrary

*** Variables ***
&{Dict1}     key1=value1

*** Test Cases ***
    
Testcase 1
    SomeLibrary.SomeFunction  ${Dict1}

But is it possible to pass a dictionary to SomeLibrary.SomeFunction without declaring a variable? The following code is just for visualisation:

*** Settings ***
Library             Collections
Library             SomeLibrary

*** Test Cases ***
    
Testcase 1
    SomeLibrary.SomeFunction  &{key1=value1}

Upvotes: 1

Views: 192

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386020

Starting with robotframework 3.2 you can use inline python evaluation, which allows you to put any python code you want inside ${{ and }}:

SomeLibrary.SomeFunction  ${{ {'key1': 'value1'} }}

Upvotes: 2

Related Questions