Script Branching Logic

Last modified on May 13, 2024
Note: To use this guide, you need to know how to use AlertSite DéjàClick transaction recording tool. If you do not have the DéjàClick toolbar in your Firefox browser, go to the DéjàClick Downloads page to download the DéjàClick add-on and additional modules (TrueScreen and ImageMagick). If you have never used DéjàClick before, please go to the DéjàClick Quick Start Guide. After you have become comfortable with recording DéjàClick transactions, you will be able to move on to this more advanced feature.


Branching Logic is a DéjàClick feature that allows a web transaction script to use conditional tests to branch if specific conditions are met. There are many circumstances under which you may want to navigate to alternate web pages in one transaction, for example:

  • Out-of-inventory condition – When you are monitoring your order processing flow and an item is out of stock, you don't want the transaction to report an error. Instead, you want the script to handle it elegantly and report success. You can set up a branch that will select an alternate item if the first one isn’t available.

  • A/B testing – When your organization performs A/B testing, your monitor won’t be able to predict which page will be served. In that case, you can set up branches that key in on a known object in each of the versions and have your script kick off the appropriate path based on what it has been served.

  • Conditional monitoring – You can monitor your mobile site by first entering the main domain. If there is an issue on the main site, the replay will stop without error notification since it couldn’t execute the mobile test.

  • Maintenance mode – You can set up breakpoints at pages undergoing maintenance or changes, record a new series of steps, and set the branching rule to take that path temporarily. When the changes have been completed, the branching rule can be removed and the added steps will be ignored.

  • Script editing - You want to completely change the last three steps of your script. Instead of having to re-record the script from the changed event on down, now you can add a branch with the new events, or add a branching rule to skip events that need to be deleted.

DéjàClick Script Branching facilitates the handling of these situations and others. Branching lets you specify when certain error conditions on certain events should be ignored, so that when those errors occur, the transaction will not raise an error but will continue on to the next event. Branching also provides the option of skipping events, jumping forward to another event, or stopping replay before the end of the script is reached. Finally, Branching includes the option of recording a new "branch", which is an alternate sequence of events that can be replayed as part of the main script.

The addition of branching in DéjàClick requires the use of some decision logic so that a script could include multiple recorded sequences of events and the conditional logic would decide between them at replay time. This means that DéjàClick could replay a different sequence of events each time the transaction runs.

Configuration process

It is advised that you spend some time designing the logic flow of your transaction. A flowchart or decision table can help you visualize how you expect to navigate through the website depending on conditions. Once you have a good handle on the process, it will make recording and branching configuration easier.

To utilize Branching, open the Script Properties sidebar and set the DéjàClick Display Level to Advanced to show the Branching Rules panel at the bottom.

Branching rules

The Branching Rules panel is available for both Actions and Events.

When you pause during script replay, you will be able to insert a target branch that will be taken depending on conditions you select within the Branching Rules.

The general procedure is outlined as follows:

  1. Record the main leg of your transaction

  2. Right-click on the Action or Event you want to stop at and click Pause


    Alternatively, click on the down-arrow next to the Replay button, select Replay Next Action

    Replay drop-down  menu

    Then click Replay until you arrive at the Action you want to branch from.

  3. When paused, click the down arrow next to the Record button to show 2 selections.

    Select Add to new branch to create a branch with a new set of steps to execute.

  4. Click Record to create the branch with the new steps.

  5. Set up a Branching Rule based on a specific condition to control which part of the script to play.

  6. Repeat Record > Add New Branch for additional branches.


You want to exercise your web application's Item Search functionality. You want to make sure that the page displays "item is available" if the search term is found; otherwise, it will display "out of stock". The basic flow is:

  • If the item is found, select the item, then proceed to the shopping cart.

  • If the item is not found, select a second-choice alternative.

  • If that item is not found, go to the "Contact Us" page.

The sections below will show how to implement Branching in the transaction to accomplish the desired logic flow. Please note that this example is for illustration only and does not refer to any specific website application.

Record the Transaction

To set up this scenario, first record the initial search.

Search for First Choice Item
  1. Click on the DéjàClick toolbar.

  2. Enter starting URL and go.

  3. Enter the item you want into the Search box and go.

  4. When the item page is displayed, click on the DéjàClick toolbar to open the validation pane below the toolbar and select Keyword.

  5. Hover over "item is available" on the page, then click to select it.

  6. Click again to close the validation pane.

  7. Click to select the item and proceed to the shopping cart.

  8. Click .

The main part of your script is now done. To perform a search for the alternate item, you will want to navigate to a different set of steps. You can add a branch to do that search by replaying the main script and stopping at the Action where you enter the search term.

Create a Branch for the Second Choice Item Search
  1. Right-click on the Action where the initial search was entered and pause the replay.

  2. Click on the DéjàClick toolbar.

  3. When replay stops at the Action search, click the down arrow next to , and select Add to new branch.

  4. Click  – [Branch 1] will appear at the bottom of the script tree in the sidebar.

The Branch starts a new section and queues you there. You are now ready to record the steps for the alternate item.

Search for Second Choice Item
  1. Click the Search box to look for the alternate item.

  2. Enter the alternate item and go.

  3. When the item page is displayed, click on the DéjàClick toolbar (Keyword is already selected).

  4. Hover over "item is available" on the page, then click to select it.

  5. In the Add Keyword Validation dialog, click OK.

  6. Click to close the validation panel.

  7. Click the item to select it and proceed to the shopping cart.

  8. Click .

Now you have the second part of your script done. The third part of the transaction, what to do when the second-choice item is out of stock, will go to the Contact Us page. Simply record another Branch that navigates to Contact Us.

Neither Item Exists - Contact Customer Service
  1. Click on the DéjàClick toolbar.

  2. Replay stops at the search Action because the Pause is still in place from the first Branch.

  3. Click (Add to new branch is still selected)

  4. Click the Contact Us link in website header, footer, or sidebar.

  5. Click .

The script has been recorded with the steps that will be taken based on the search results during regular replay. Now add the Branching Rules that the transaction will follow.

Add Branching Rules

Branch 1: First-Choice item not found
  1. In the script tree, click on the Action that does the search of the first-choice item.

  2. In the Properties section of the sidebar, scroll to the bottom and click Branching Rules.

  3. Click the Add button to display the Add Branching Rule dialog.

    Add branching rule
  4. Enter a description of the rule in the Name field.

  5. Select the "trigger" from the drop-down list.

    Replay status

    We will select Replay status is (the Status Code selection dropdown is hidden if Always or Never is chosen).

  6. Choose the Status Code to trigger on:

    Status Code

    In our example, we want to branch when the keyword validation fails.

  7. Select the action to perform:Stop Replay or Jump to.

    Stop or Jump

    We want to jump to a different part of the script.

  8. The next selection is a drop-down list that will change depending on the existence of other branches and how many there are:

    Main Script

    We would select Branch 1 for this condition.

  9. Select whether you want to branch to the Action or Event within the main script or branch.

    Action or Event number

    The valid selections are displayed in the dropdown.

  10. We can also specify the Action or Event number to branch to:

    Action number

    This number changes depending on the Action or Event selection.

  11. You can have more than one Branch Rule, depending on your requirements. In that case, you can set their sequence order:


    If there is only one branching rule, this field does not appear.

  12. Click Apply.

Branch 2: Second-Choice item not found
  1. In the script tree, click on the first Action in Branch 1.

  2. Click Branching Rules in the Properties section of the sidebar.

  3. Click the Add button to display the Add Branching Rules dialog.

  4. Enter the description in the Name field.

  5. Select Replay status is.

  6. Choose 5) Validation Failed.

  7. In Do this, set Jump to - Branch 2 - Action 1.

  8. Click Apply.

Next, test the branching logic for the conditions you have set to make sure it performs as expected. This requires manipulating the script properties, in this example the Event Input, so that the conditions will be met during replay.

Test Branching Logic

First Choice Found
  1. Remove the Pause by right-clicking the Action with Pause enabled and click Pause to deselect it.

  2. Click .

  3. The script will replay through the main script and complete.

First Choice Not Found, Second Choice Found
  1. In the script tree, click the Event Input HTML Element <INPUT> under the Action where you made your first selection.

  2. In the Properties sidebar, expand the Event Input section.

  3. Change the text, which was the item you searched for, to some random characters

  4. Click Apply.

  5. Click Replay in the DéjàClick toolbar.

You will see the progress in the script tree as the transaction is replayed. When it gets to the Event that does the keyword validation for "item is available", it will fail because the event input, now random characters, will not be found. The main script Branching Rule says: when keyword validation fails, Jump to Branch 1 Action 1. This is the section to search for the alternate choice. You will see the progress icon, a green check mark, skip to Branch 1. The steps in this branch will be executed and the script will complete.

Now, test the logic if the alternate choice is not found.

  1. In the script tree, click the Event Input HTML Element <INPUT> under the Branch 1 Action 1 where you made your alternate selection.

  2. In the Properties sidebar, expand the Event Input section.

  3. Change the text, which was the item you searched for, to some random characters.

  4. Click Apply.

  5. Click on the DéjàClick toolbar.

As the transaction is replayed, you will see it progress from the main script to Branch 1, where the keyword validation "item is available" will fail when the Event is checked. The Branch 1 Branching Rule says: when keyword validation fails, Jump to Branch 2 Action 1. The rule for that Event causes execution to jump to Branch 2, and the script will complete.

When you are satisfied that the transaction performs all branches as expected, return to the Properties sidebar and restore the correct text strings in both Event Input panels that were changed.

Note: Replay will automatically stop when it reaches the end of a script, whether the main script or a branch.

Upload to Account

Now that the transaction is set up to handle the two possible conditions you expect, you can upload it to your AlertSite account for monitoring.

  1. Select  > AlertSite Login and provide your account credentials.

  2. Select  > Upload Recording.

  3. Fill in the information in the Upload Recording dialog and click OK.

  4. The Manage Transaction page will appear in a new browser tab; modify any of the fields as needed and click Submit.

The Dashboard will update shortly with the monitoring data for the new transaction.


  • Looping is not allowed. You cannot jump back to a previous event within the main part of the script or within a branch. You can:

    • Jump forward to a later event in the main part of the script or in a branch.

    • Jump between the main part of the script and a branch.

    • Jump between branches.

  • You will not be able to add a branching rule to the last event of a script that does not have at least one branch. Otherwise, the Target section of the Add Branching Rules dialog for that event will be grayed out since there are no valid targets to jump to. You can add a branching rule to any of the previous events in the script as long as it jumps forward to a later event.

See Also

Configuring Scripts

Highlight search results