cancel
Showing results for 
Search instead for 
Did you mean: 

ReadyAPI-how to make a teststep wait to run after fetching token

Highlighted
Frequent Contributor

ReadyAPI-how to make a teststep wait to run after fetching token

In a project I need to get a token first, and then run the teststep.

I have declared the token in the Auth Manager on parent testcase and pointed to all child testcases to 'Inherit from parent'. The token is retrieved correctly.

AuthManager.png

I also have automated the check on that token for existence. so if it isn't usable anymore, a new token should be asked by the Tokenizer automatically.

AutomatedScript.png

Now, I have testcases that have a high latency for the moment, a bug that is known and that they are fixing, but I would like the teststep to wait for e.g. 30 seconds to run and make sure the token is active.

I have inserted a "Delay" object in the testsuites, but I was actually wondering if this is really doing what it should?

TestSuite.png

Does anybody has an idea please?

Thanks in advance!

9 REPLIES 9
Highlighted
Community Hero

Re: ReadyAPI-how to make a teststep wait to run after fetching token

Hey @AboveAndBeyond,

Youre wondering if the Delay step is really doing what it should be? Can you clarify why you think its not behaving as youd expect?

I did notice that you mention a latency of 30 seconds and the value in your screenshot is '3000'. Isnt units of measurement for the Delay step in milliseconds? I.e. 3000 milliseconds = 3 seconds.
30000 milliseconds = 30 seconds.

Ta

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Frequent Contributor

Re: ReadyAPI-how to make a teststep wait to run after fetching token

Hi @richie 

Thanks for your feedback. I've adapted the time as I didn't understood this measurement correctly.

Concering the fact if it really work or not is this:

As I have put the tokenizer in Auth manager, and the REST Request is fetching this token in it's request, I don't know the sequence of actions in a testsuite. How is it executed sequentially?

A request has an Endpoint and a resource and parameters, it has (in this case) a token that should be used.

so how is the TestSuite actually executed?

* TestSuite click --> execute all testcases in me

* ReadyAPI searches for the first testcase --> start testcase

* ReadyAPI finds a first teststep that is a Delay --> execute delay of (here ) 30 seconds

* ReadyAPI finds a second teststep that is a Rest Request --> look into the Rest Request for Endpoint and then look if you need a token --> Execute.

 

If this is the way how it goes, the delay has no use. I need a delay after the Rest Request has found the token to fetch, and delay the proces then. 

So actually, to my understanding, that Delay has no use in my case.

 

Might ReadyAPI look in the teststep  Rest Request at the token first before looking at the endpoint, then I should script something  to delay the execution of the Rest Request in scripting or something like that.

So, yhé, now that I'm writing this I notice that I explained it wrongly. Sorry. I know that it works, because I see the countdown, but not for my case....

Actually I think I need to use EventHandlers for this but I have no clue about scripting....

 

Regards,

AAB

Highlighted
Community Leader

Re: ReadyAPI-how to make a teststep wait to run after fetching token

@AboveAndBeyond , As i have understood, you need to wait till the desired condition gets satisfied, so in that case Delay won't help you need to write some logic(script) so that you can let your script wait till the till desired condition gets satisfied.

 

Let me know if you need help at coding part, will be happy to help 🙂

 


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Highlighted
Frequent Contributor

Re: ReadyAPI-how to make a teststep wait to run after fetching token

@HimanshuTayal 

 

That would be great if you could help me because indeed, I'm not a coder 😉

So yes, please give me a script for this. And where should I put it? in an assertion? On testcase level in a setup script?.....

 

Thanks in advance!

Regards, AboveAndBeyond

Highlighted
Community Leader

Re: ReadyAPI-how to make a teststep wait to run after fetching token

@AboveAndBeyond : You can PM me with some details.

 

Like where your token is generating where it is getting stored how you are checking if is generated.


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Highlighted
Community Hero

Re: ReadyAPI-how to make a teststep wait to run after fetching token

Hey @HimanshuTayal,

If you manage to put some code together to extract the token value without executing the REST step, you might want to make the post sticky or i think theres a "handy stuff" section for cool stuff.
Ive seen lots of posts in the last year about doing this.

Just a suggestion fella,

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Community Leader

Re: ReadyAPI-how to make a teststep wait to run after fetching token

@richie : Yes that will need lot of groovy code

 

@AboveAndBeyond : those screenshot didn't help me, could you please share project with me if possible

 


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Highlighted
Frequent Contributor

Re: ReadyAPI-how to make a teststep wait to run after fetching token

@HimanshuTayal 

Sorry sir, I can't share that project with you as this is Governmental property.

 

Kind regards,

AboveAndBeyond

Highlighted
Community Manager

Re: ReadyAPI-how to make a teststep wait to run after fetching token

Thank you Richie for the idea, yes, the techcorner tag is how we can keep the awesome stuff in one place🙂

 

@HimanshuTayal there would be no way to proceed without the actual project, would there? Or maybe kind of a sample project from @AboveAndBeyond would help?


Sonya Mihaljova
Community and Education Specialist
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
The new challenge is here!

Create a script to сhange an XPath Match assertion to a JSONPath Match assertion for the TechCorner tag!


Scripts created in July:
- A script to generate an email when an assertion fails
- A script to change the request body before sending it to the server
Top Kudoed Authors