cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional GoTo: how does it work?

SOLVED
AAB
Frequent Contributor

Conditional GoTo: how does it work?

Hello,

I was looking into the Conditional GoTo step but it doesn't seem to work for me.

 

I set up a virtual service to get a response.

First request is a HappyFlow that recieves this:

 

{
   "userId" : "3fa85Ki45Eue74562BaFc2c963Zw6afa6",
   "personNumber" : 123456789858,
   "firstName" : "Maria",
   "lastName" : "Peeters",
   "emailAddress" : "maria.peeters@mailbox.be",
   "creationDate" : "2020-01-15T00:00:00.000Z",
   "isPreferredNotary" : true,
   "vaultId" : "5Ez9PKi45Eue74562BaFcyTc75Zw6afa6"
}

 

I've put a GoTo after this request that states that if the value of the personNumber is present and correct, it will go to the next REST Request. 

The next request is a request that should check if the personnumber is not there. This step works.

When I test the GoTo step I'm getting this message:

AAB_1-1620217265126.png

 

 

Although the number is present! (teststep is green)

I guess the notation is wrong?

How can I get the testcase to stop if the condition is not met? Thus, not executing the "bad request"?

If I would be able to do so, will the testcase run be red then?

 

Thanks in advance,

AAB

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
nmrao
Community Hero

Re: Conditional GoTo: how does it work?

Have you referred any documentation which is confusing regarding goto?

 

Here is how it works:

User have to define what to do if condition is passed and otherwise.

 

In the below case, two conditions defined and two target steps are configured where to go when particular condition is satisfied.

 

Test executed twice

- first time found no_matching so again executed the request step

- second time, condition is evaluated to true, proceeded following step to Conditional Goto as you see in the below screen shot.

NOTE that for each condition, the target step is different based on what user like to do.

Hope this helps!

nmrao_0-1620286438575.png

 



Regards,
Rao.

View solution in original post

7 REPLIES 7
nmrao
Community Hero

Re: Conditional GoTo: how does it work?

The xpath expression result should be boolean.



Regards,
Rao.
AAB
Frequent Contributor

Re: Conditional GoTo: how does it work?

Hi Rao,

 

Thanks for your quick response. I found how to do so but the teststep still continues to the next one when boolean is false. How can I make it stop at the GoTo please?

The testcase option is set to 'abort test if an error occurs'

AAB_0-1620282539085.png

 

The conditional 'GoTo' expression has been changed to this:

declare namespace ns1='http://localhost/digital-vault/itp/v0/vault-owner/12345678958';
//ns1:Response[1]/ns1:personNumber[1]/text()="12345678958"

 

I'm getting response "No condition true for current response in [HappyFlow] but it still runs the Bad Request.

AAB_1-1620282673020.png

 

What can I do to make it stop and fail the testcase please?

 

Kind regards,

AAB

AAB
Frequent Contributor

Re: Conditional GoTo: how does it work?

it's even a wierd thing. If I choose the right NRN in the GoTo I get "Missing matching condition, moving on".

I think I don't grasp that GoTo thing.

@Anastasia @nmrao @Himansu could anybody explain that to me please?

 

Thanks in advance,

AAB

nmrao
Community Hero

Re: Conditional GoTo: how does it work?

Have you referred any documentation which is confusing regarding goto?

 

Here is how it works:

User have to define what to do if condition is passed and otherwise.

 

In the below case, two conditions defined and two target steps are configured where to go when particular condition is satisfied.

 

Test executed twice

- first time found no_matching so again executed the request step

- second time, condition is evaluated to true, proceeded following step to Conditional Goto as you see in the below screen shot.

NOTE that for each condition, the target step is different based on what user like to do.

Hope this helps!

nmrao_0-1620286438575.png

 



Regards,
Rao.

View solution in original post

nmrao
Community Hero

Re: Conditional GoTo: how does it work?

In the previous reply,
The REST request is executed again and again if the phone number is not equal to the desired value from its response.

Ideal use case that, a rest request ( can be other requests as well) can generate an event in the application.
And later user like make another request to know the status of the event, say got the status as in progress in the response and it may take a while to complete the event. However, user can only proceed and do further operations only if the event is complete. So here user need check if the status is not complete then again get the event status after a specific delay. If the status is complete then then proceed.

So have two conditions defined here, what to do if event is complete and not complete.

 

Conditional GOTO works as if .. else block in programming.



Regards,
Rao.
AAB
Frequent Contributor

Re: Conditional GoTo: how does it work?

Hello Rao,

 

Thanks for the insides and explanation. Now it is indeed clear (if....else). Yes I read de documentation on smartbear and try to execute it but it didn't work. That's why my question.

 

Meanwhile I found out why it wasn't working, but your explanation helped me!. apparently the number wasn't correct. (2 numbers changed place at the end  😞  ) My bad!

 

Thanks for your time!

Kind regards,

AAB

 

nmrao
Community Hero

Re: Conditional GoTo: how does it work?

Yeah documentation isn't clear enough with example for Conditional Goto.

Hope Smartbear team improves it.


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors