If...Else Logical Step Fails


I added an If...Else logical step to my test. When the verification attached to the IF portion is true, that branch correctly executes. However, when that verification is false, the ELSE branch does not execute and the test fails.


The issue is likely with the verification attached to the IF portion. Let's say it verifies the element is visible. When the element does not exist and cannot be found, the verification cannot be performed, the ELSE portion is not executed, and the entire test fails.


The fix is to record a new verification on the element and attach it to the IF. This time, record a Wait - element exists step. This way, when the element does not exist, the ELSE portion will correctly execute and the test will not fail.


Here's a basic demonstration. Create a test with these steps:

  1. Navigate to www.bing.com.
  2. Enter telerik in the search box.
  3. Click the search button.
  4. Click the first search result: NETUILink.



  6. Using Steps Suggestions, create the verification that we'll attach to the IF statement. Highlight NETUILink in the Elements Explorer.
  7. Click the Step Suggestion gear icon.
  8. Double click the Exists 'NETUILink' verification to add it to the test. You can optionally right click this step and Change Role > Set as Wait.



  10. Add an If...Else step with the Logical button in the Add ribbon.
  11. Hover the IF step and click the green plus (+) sign.
  12. Click green plus next to the newly created verification.
  13. Drag the Click 'NETUILink' step into the IF portion.
  14. For the ELSE portion: copy and paste step 1, change its URL, and drag it into the ELSE. (Ensure you drop it inside the ELSE and not after it.)



  16. Execute the test. The element is found, the IF portion executes, and the NETUILink element is clicked.
  17. Now double click step 2 and change the text. We want the first result to not match the NETUILink. Since that element does not exist this time, the ELSE portion is executed: