cancel
Showing results for 
Search instead for 
Did you mean: 

how to extract text from Json Node

SOLVED
Highlighted
New Contributor

how to extract text from Json Node

Hello,

 

Can anyone help me in extracting text value from URL.

I have a Json node response in the following format:

JSON node =url

Value=http://aaa-test-bbb.websites.net/sample/c6e7b442-a33c-4bd3-bbbb-ef2d5873b661/l/TSKR4AM/details

I need to extract and pass the text highlighted in bold can be through property transfer or groovy script.

 

Appreciate quick response.

Thank you.

Brij

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Staff

Re: how to extract text from Json Node

Hi,

 

It is not possible out of the box since we can get the URL with point and click but to extract a resource path value you need groovy,

https://www.soapui.org/getting-started/point-and-click-testing/point-and-click-with-xpath.html

 

You can add a groovy script test Step for example if,

def str ="http://aaa-test-bbb.websites.net/sample/c6e7b442-a33c-4bd3-bbbb-ef2d5873b661/l/TSKR4AM/details"

def vals = str.split("/")

def token = vals[6].toString()

testRunner.testCase.setPropertyValue("token",token)

 

You can then add this expansion to substitute the value,${#TestCase#token}

 

Thanks

 

 

 

 

 

 



Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today

View solution in original post

2 REPLIES 2
Highlighted
Staff

Re: how to extract text from Json Node

Hi,

 

It is not possible out of the box since we can get the URL with point and click but to extract a resource path value you need groovy,

https://www.soapui.org/getting-started/point-and-click-testing/point-and-click-with-xpath.html

 

You can add a groovy script test Step for example if,

def str ="http://aaa-test-bbb.websites.net/sample/c6e7b442-a33c-4bd3-bbbb-ef2d5873b661/l/TSKR4AM/details"

def vals = str.split("/")

def token = vals[6].toString()

testRunner.testCase.setPropertyValue("token",token)

 

You can then add this expansion to substitute the value,${#TestCase#token}

 

Thanks

 

 

 

 

 

 



Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today

View solution in original post

Highlighted
New Contributor

Re: how to extract text from Json Node

Thanks a ton, it worked like charm.

New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Filtering data retrieved from a DataSource

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors