Freddy
Freddy

Reputation: 521

In robotframework is it possible to pass keywords to variables?

What I am attempting is the following:

*** Settings ***
Library    DateTime

*** Variables ***
${DATE}    get current date    result_format=%Y-%m-%d
${TODAY}    today is ${DATE}

However, when attempting to run I get the following:

[ ERROR ] Error in file '~/test.robot': Setting variable '${TODAY}' failed: Variable '${DATE}' not found.

Upvotes: 0

Views: 597

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386372

The variable table cannot call keywords. You can only give it static values.

From the robot framework user guide (emphasis mine):

The most common source for variables are Variable tables in test case files and resource files. Variable tables are convenient, because they allow creating variables in the same place as the rest of the test data, and the needed syntax is very simple. Their main disadvantages are that values are always strings and they cannot be created dynamically. If either of these is a problem, variable files can be used instead.

Upvotes: 4

Related Questions