0

I'm currently using Robot Framework for creating UI automation for our project. And I would like to know how to assign defined keyword as a variable value and how to run variable as keyword?

2
  • 1
    For me it's unclear what you are asking for. You want to know how you can store a value from a keyword which have [Return] statement or you are asking something else? Please update you question with more details.
    – chesthar
    May 4, 2021 at 19:20
  • You should share the code to we understand and perfaps help.... Jan 28, 2023 at 19:15

2 Answers 2

0

Robot framework has for this prepared keyword Run Keyword, where you supply actual keyword to run as a parametr - stored in variable.

0

You can assign a defined keyword as a value of a variable in Robot Framework using the Set Variable keyword.

For example:

*** Variables ***
${KEYWORD_NAME} My Keyword

*** Keywords ***
My Keyword
Log To Console This is my keyword.

*** Test Cases ***
Test Keyword as Variable
Set Variable ${KEYWORD} Evaluate ${KEYWORD_NAME}
Run Keyword If '${KEYWORD}' == 'My Keyword' ${KEYWORD}

In the above example, the value of the KEYWORD_NAME variable is assigned to the KEYWORD variable using the Set Variable keyword. And then the Run Keyword If keyword is used to run the KEYWORD as a keyword, if it's equal to My Keyword.

You can also use the Evaluate keyword to run a variable as a keyword, as shown in the example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.