Forum Discussion

AAB's avatar
AAB
Regular Contributor
4 years ago

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.

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.

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?

Does anybody has an idea please?

Thanks in advance!

9 Replies

  • richie's avatar
    richie
    Community Hero
    Hey AAB,

    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
    • AAB's avatar
      AAB
      Regular Contributor

      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

      • HimanshuTayal's avatar
        HimanshuTayal
        Community Hero

        AAB , 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 🙂