In this post, we will start working with Error/Exception handing in Coded UI Testing. In the last post, we discussed about Assertions in coded UI testing. In Assertions we saw how coded UI testing stops its execution without moving forward to the next operation if the Assertion fails. Even though the behavior is expected, in some situation we would like our test to move forward if there happens any failure due to Validation
Thus in this topic, we will discuss how to handle Error/Exception in code, if there happens any failure only during Validation process but not during
Finding of Element
Performing operation in Element like enter text, click etc
Setting a property for the element
Please don’t try to add exception handling which perform certain operations in the UI, since if that operation exception itself is handled, then that may result in unexpected behavior of test.
We are going to handle Error/Exception in Coded UI testing using try .. catch block of C#.
Here is the complete video of the above explanation
Here is the code snippet of the same code which we discussed in previous post on Assertion in coded UI testing