How to store Value returned from 1st keyword and then using that value in another keywords without running the 1st keyword again in robot framework
dhingrachirag opened this issue · comments
dhingrachirag commented
I struck in one problem in which I want to store Value returned from 1st keyword in variable during initial run and then using that variable in another keywords without running the 1st keyword again .
I tried below code but not able to resolve the issue.
Create Account Post Request
${response}= call post request ${headers2} ${base_url} ${base_url_account} ${account_data}
log ${response}
Should Be True ${response.status_code} == 201
${account_id} get value from json ${response.json()} id
log ${account_id}
RETURN ${account_id}
Get Network ID --> [While running this keyword Create Account Post Request will run again which updates the account ID which I don't want]
${acc}= Create Account Post Request --> [During this It will run Create Account Post Request again which I don't want]
log ${acc}
My questions are :
- How to use account_ID in any keywords without running the first keyword again and again ?
- How to use return value from 1st keyword in any other keywords? [Condition, I don't want to run 1st keyword again to get the return value]
Below scenario is expected :
- 1st Keyword ran
- 1st Keyword return some value
- Store value in some variable
- Use returned value anywhere in the suite file, in any keyword within the suite, in any test case .
lucagiove commented
Hi, this is more a Robot Framework generic kind of question, there are multiple ways to achieve what you describe.
Please have a look at the RF documentation.