Ask a Question

How to get the start time of a request and of the response in groovy script ?

SOLVED
LucN
Occasional Contributor

How to get the start time of a request and of the response in groovy script ?

Hello eveyrone ! 

 

I have been searching a lot about that and didn't find an answer. I would like to know how in groovy script, I can have the time of whenthe request was send and the time of when the response was send ? 

 

Thanx in advance for your help ! 

 

Luc. 

7 REPLIES 7
jsheph01
Contributor

There is a way to get the time the request was sent and how long it took to get a respose. You can add those two together to get the response time.

 

Class RestResponseMessageExchange

 

messageExchange.getTimestamp() 
messageExchange.getTimeTaken()
Lucian
Community Hero

I wrote about something similar at https://community.smartbear.com/t5/SoapUI-Pro/Sharing-is-caring-groovy-script-to-log-the-test-execut...

 

Can you see if this helps you?



If my answer helped please click on the 'Accept as Solution' button.
LucN
Occasional Contributor

It's not clear to me because I get the following result with getTimestamp : 1553695803464  How is it a date ? 

Sorry, guess I should have mentioned that timstamp is in unix time. Add this to convert it from unix time.

 

 Date date = new Date(messageExchange.getTimestamp() );

 

 

 

 

nmrao
Champion Level 3

Please note that the above script (messageExchange) works in only Script Assertion.


Regards,
Rao.
nmrao
Champion Level 3

That is time in Milli seconds.


Regards,
Rao.
LucN
Occasional Contributor

Thanx It works 😄 And thx eveyrone for your help ! 

cancel
Showing results for 
Search instead for 
Did you mean: