python requests - How to create a global variable for session and use it across test cases ( RobotFramework,REST API ) -
can let me know how create global session variable , session variable should used across keywords/testcases . have tried following way , getting error ${itoc_session} not found.
*** settings *** library requestslibrary library collections *** keywords *** create session server @{auth}= create list admin admin123 create session httpbin https://host141.swlab.net:71/ auth=@{auth} set global variable ${itoc_session} httpbin policy server ${resp}= request ${itoc_session} uri=/policies/ log ${resp.status_code} :for ${item} in @{resp.json()} \ log ${item} \ ${get_policy_id}= variable value ${item['id']} \ ${get_policy_name}= variable value ${item['name']} \ log ${get_policy_id},${get_policy_name} set global variable ${policy_id} ${get_policy_id} policy policyid ${res}= request ${itoc_session} uri = /policies/${policy_id} log ${res} log ${res.json()['name']} , ${res.json()['extreference']} *** test case *** get_policy_id policy server get_policy_details policy policyid
you never call create session server
, variable never gets set.
Comments
Post a Comment