While getting the access token , error found

Looking at your function to start the execution in robot framework

def run_robot_script(access_token,robot_file ):
  os.system(f"robot --variable access_token:{access_token} {robot_file}")

In general, I would recommend using the python entry points that robotframework offers to start the test execution instead of os.system. Either by using robot.run_cli or robot.run
But the 2nd thing is:
You use the --variable option set overrvide the Variable with the name access_token.
When you do that, it means that the variable ${access_token} is defaulted during that test run.
So you should be able to do a
Log ${access_token}
anywhere in your tests and you should see it’s value.

There is no need to do a
${access_token}= Get Environment Variable access_token
before (as you showed in your snippet). If you do that, Robot Framework would try set the variable ${access_token} again by retrieving an environment variable value - this is not needed as you already passed the variable directly from the command-line.

We need to distinguish here between the environment variables and the robot variables.
When you hand over robot variables using --variables myVar:myValue , they are globally available in your test run.

1 Like