We get the following error in Robot Framework "Keyword 'OperatingSystem.Create File' got positional argument after named arguments"

python, robotframework

Solution

What the error literally means is that you can't put named arguments (eg: `x=y`) before positional arguments. In the code you show in your question you are giving the keyword a named argument of `content=${QPID_COMMAND}` followed by another argument that begins with `${QPID}`.

Could it be that you have a typo, and that there shouldn't be two spaces between those two? Robot is seeing those two spaces before `${QPID}` as a column separator, so it thinks `${QPID}` is a separate argument rather than as part of the content.

Problem

The below robot framework keywords were used in one of our test cases: ``` ${data_dict}= Create Dictionary apiproxy ${APIPROXY} request_verb ${REQUEST_VERB} basepath **${basepath}** pathsuffix **${pathsuffix}** ${data_file}= generate data ${data_dict} Create File test.sh content=${QPID_COMMAND} ${QPID} -org ${ORG} -env ${ENVIRONMENT} -exchange ${exch_name} -queue ${queue_name} -useProtoBuf -noOfMessages ${msg_count} -batchsize 1 -config ${data_file} ``` Here the value of `${basepath}`: `${basepath} = ${EMPTY} and ${pathsuffix} = /testpath/` When I try to run this, the error `"Keyword 'OperatingSystem.Create File' got positional argument after named arguments"` is displayed. I was not able to access the Robot framework Docs.

Original source