Hello all,
I am unsuccessfully trying to achieve the following (simplified):
Calculate ${operation} of ${a} and ${b}
Calculate sum of ${a} and ${b}
${result} = Evaluate ${a} + ${b}
Calculate product of ${a} and ${b}
${result} = Evaluate ${a} * ${b}
So I would like to call a keyword based on ${operation} type, since the selection will vary depending on test and be dynamically set.
When I try to run the test, I get:
No keyword with name ‘Calculate ${operation} of ${a} and ${b}’ found.
*** Test Cases ***
Embedded arguments
Select cat from list
Select dog from list
*** Keywords ***
Select ${animal} from list
Open Page Pet Selection
Select Item From List animal_list ${animal}
Thank you for your reply @Many .
I have tried using embedded arguments to achieve this result. Do you see any mistake in the example I posted?
I can’t figure what I am doing wrong.
Edit:
I think my example is opposite to yours.
In my case, keyword names are defined with static text and called with dynamic variable.
In your case, keyword has an embedded argument and is called with static string in the name that gets resolved to argument, if I understood correctly.
Calculate ${operation} of ${a} and ${b}
IF “${operation}” == “sum”
Calculate sum of ${a} and ${b}
ELSE IF “${operation}” == “product”
Calculate product of ${a} and ${b}
END
RF evaluate the keywords before running the tests.
So RF can not link “Calculate ${operation} of ${a} and ${b}” to “Calculate sum of ${a} and ${b}”
The other solution will be to define only “Calculate ${operation}of ${a} and ${b}” and use the IF statement to perform directly the required actions according to ${operation}.
Calculate ${operation} of ${a} and ${b}
IF “${operation}” == “sum”
${result} = Evaluate ${a} + ${b}
ELSE IF “${operation}” == “product”
${result} = Evaluate ${a} * ${b}[Arguments] ${col1} ${col2}
END
[Return] ${result}