# Can I do conditional branching in a Synthetics Test ?

**URL:** <https://community.dynatrace.com/t/can-i-do-conditional-branching-in-a-synthetics-test/11643>\
**Category:** Synthetic Monitoring\
**Tags:** synthetic-monitoring\
**Created:** [March 3, 2020, 8:25pm UTC](https://community.dynatrace.com/t/can-i-do-conditional-branching-in-a-synthetics-test/11643 "2020-03-03T20:25:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anupam\_Kumar](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Anupam\_Kumar](https://community.dynatrace.com/u/Anupam_Kumar)\
**Post date:** [March 3, 2020, 8:25pm UTC](https://community.dynatrace.com/t/can-i-do-conditional-branching-in-a-synthetics-test/11643/1 "2020-03-03T20:25:27Z")

</div>

If validation on a certain step fails I can choose an alternate path ?

For example - if validation on step 5 fails goto step 17 else goto step 23 or something equivalent to that

---

<div class="post-metadata">

**Author:** ![justin\_hogue](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/justin_hogue/32/19679_2.png) [@justin\_hogue](https://community.dynatrace.com/u/justin_hogue)\
**Post date:** [March 3, 2020, 8:36pm UTC](https://community.dynatrace.com/t/can-i-do-conditional-branching-in-a-synthetics-test/11643/2 "2020-03-03T20:36:36Z")

</div>

Hello,

I haven’t tried this myself but you may be able to achieve this by using JavaScript events. Through the use of the JavaScript API you should have the ability to skip execution of events to create a dynamic workflow. I’ll provide a link with documentation on this below.

> **[Browser clickpath events in Classic](https://docs.dynatrace.com/docs/observe/digital-experience/synthetic-monitoring/browser-monitors/browser-clickpath-events)**
>
> Learn about the event types created when recording a browser clickpath.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Anupam\_Kumar](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Anupam\_Kumar](https://community.dynatrace.com/u/Anupam_Kumar)\
**Post date:** [March 4, 2020, 12:17am UTC](https://community.dynatrace.com/t/can-i-do-conditional-branching-in-a-synthetics-test/11643/3 "2020-03-04T00:17:47Z")

</div>

So I can only skip steps… and ‘skip them forward’ … Any clever way to ‘jump back’ a few steps ? Are negative numbers allowed as parameters to skip step function ?

---

<div class="post-metadata">

**Author:** ![hannahmac](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/hannahmac/32/41823_2.png) [@hannahmac](https://community.dynatrace.com/u/hannahmac)\
**Post date:** [November 18, 2021, 1:24pm UTC](https://community.dynatrace.com/t/can-i-do-conditional-branching-in-a-synthetics-test/11643/4 "2021-11-18T13:24:39Z")

</div>

Correct, there is no option to jump back to a previous step.

---

<div class="post-metadata">

**Author:** ![AntonioSousa](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antoniosousa/32/50_2.png) [@AntonioSousa](https://community.dynatrace.com/u/AntonioSousa)\
**Post date:** [November 18, 2021, 2:31pm UTC](https://community.dynatrace.com/t/can-i-do-conditional-branching-in-a-synthetics-test/11643/5 "2021-11-18T14:31:15Z")

</div>

[@HannahM](https://community.dynatrace.com/user/1433),

I have not tried this myself, but might need it in the following weeks. In my case, it’s like an IF THEN/ELSE needed to be involved. In each case, 3 steps. So I was imagining to test the result from the site at the end of step 2, and if it’s condition A, it would execute steps 3-5, and skip 3 events at the end of step 5. If it’s condition B, it would skip 3 events at the end of step 2, executing steps 6-8.

Does this seem feasible in your opinion? If so, it would also solve issues like the one portrayed above, right?

---

<div class="post-metadata">

**Author:** ![hannahmac](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/hannahmac/32/41823_2.png) [@hannahmac](https://community.dynatrace.com/u/hannahmac)\
**Post date:** [November 19, 2021, 11:09am UTC](https://community.dynatrace.com/t/can-i-do-conditional-branching-in-a-synthetics-test/11643/6 "2021-11-19T11:09:11Z")

</div>

Yes, this scenario is exactly what the skip clickpath events in the javascript event are perfect for.
