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:
- Navigate to www.bing.com.
- Enter telerik in the search box.
- Click the search button.
- Click the first search result: NETUILink.
- Using Steps Suggestions, create the verification that we'll attach to the IF statement. Highlight NETUILink in the Elements Explorer.
- Click the Step Suggestion gear icon.
- 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.
- Add an If...Else step with the Logical button in the Add ribbon.
- Hover the IF step and click the green plus (+) sign.
- Click green plus next to the newly created verification.
- Drag the Click 'NETUILink' step into the IF portion.
- 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.)
- Execute the test. The element is found, the IF portion executes, and the NETUILink element is clicked.
- 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: