mercredi 2 décembre 2020

Get return value from keyword from within Run Keyword If conditional Robot Framework

Usually getting the return value from a keyword isn't a big deal,

${myVar}=     My Keyword

This will work as expected.

The issue I'm trying to resolve would in cases similar to the following. I can usually find a work around but I'd like to find a better way.

Run Keyword If     '${someVar}' == 'True'     Run Keywords
     ...     Do Something
     ...     AND     ${myVar}=     My Keyword
     ...     AND     Do More Stuff

When I need to write something like this the My Keyword keyword isn't recognized as a keyword and I cannot run my test. I could pull this out of the conditional and run the keyword just before but that means I'm going to be wasting time running a keyword that should not be ran and will sometimes lead to a failure. I found this, How to get Returned value from a Keyword called under Run Keyword If in Robot Framework?, but that is for a single keyword and I'm not sure that I could expand to multiple keywords. Also, other situations may come up where there is something like the following and would further complicate things,

Run Keyword If     '${someVar}' == 'True'     Run Keywords
     ...     Do Something
     ...     AND     ${myVar}=     My Keyword
     ...     AND     Do More Stuff
     ...     AND     ${myVar_2}=     My Other Keyword
     ...     AND     Do Other Stuff

Anyone have any suggestions? Should I just break the one Run Keyword If up into several Run Keyword If 's so the I can utilize the example from the above link? I'd appreciate any suggestions.

Aucun commentaire:

Enregistrer un commentaire