cancel
Showing results for 
Search instead for 
Did you mean: 

How to transfer TestCase properties value in Authentication(Oauth2.0) Access Token field ?

ranjit96
Contributor

How to transfer TestCase properties value in Authentication(Oauth2.0) Access Token field ?

 

 

How to transfer this login and update properties value as Access Token field.jpg

 

 

Here, In "Log in and Update" testcase custom properties present "access_token".

 I want to transfer this access token value in  "get_profile" testStep  in Authentication(Oauth 2.0) Access token field.

 

 How I do it ? Please reply me .

6 REPLIES 6
nmrao
Community Hero

Re: How to transfer TestCase properties value in Authentication(Oauth2.0) Access Token field ?

Can you show the script from "access toke retrieve"?

By the you can save the token at test case or suite or project level and use property expansion in Access Token.


Regards,
Rao.
ranjit96
Contributor

Re: How to transfer TestCase properties value in Authentication(Oauth2.0) Access Token field ?

Thank you for your suggestion.

 

 I used this property expansion     ${#login and update#access_token}

 But error is shown :  

 <message>Authorization has been denied for this request.</message>

 

 It's not retrieved access_token value. Please suggest me.

nmrao
Community Hero

Re: How to transfer TestCase properties value in Authentication(Oauth2.0) Access Token field ?

Can you show the script from "access toke retrieve"?


Regards,
Rao.
ranjit96
Contributor

Re: How to transfer TestCase properties value in Authentication(Oauth2.0) Access Token field ?

def responseHeader=teststep.testRequest.response.contentAsString
def slurper = new JsonSlurper()
def json = slurper.parseText responseHeader
def token=json.access_token
testRunner.testCase.testSuite.testCases["login and update"].setPropertyValue("access_token",token)

ranjit96
Contributor

Re: How to transfer TestCase properties value in Authentication(Oauth2.0) Access Token field ?

Hi,

Can you please guide me about Property expansion for transferring  this access_token ?

 

kondasamy
Regular Contributor

Re: How to transfer TestCase properties value in Authentication(Oauth2.0) Access Token field ?

I'm taking your code as a start,

 

 

def responseHeader=teststep.testRequest.response.contentAsString
def slurper = new JsonSlurper()
def json = slurper.parseText responseHeader
def token=json.access_token
testRunner.testCase.testSuite.testCases["login and update"].setPropertyValue("access_token",token)

 You are setting the test case level property here called "access_token". You can use the property expansion as ${#TestCase#access_token}. This will work only within the test case. The property expansion has to be modified if you need to access from a different test cases.

 

I would recommend to set it as a project level property, the scope is large. Here is the reference - https://www.soapui.org/scripting---properties/property-expansion.html

 

Thanks,

Kondasamy

 

New Here?
Join us and watch the welcome video:
Top Kudoed Authors