Prerequisites
Please complete Part 4 of this tutorial before continuing.
Adding assertions for each step
When running a test, assertions help to make sure the application is behaving as per expected behavior. For the test framework, assertions can be implemented using NUnit.
Navigate back to 'And I'm in google home page' step in GoogleSearch.feature file. In this step before entering a value to search text box, we need to make sure search text box is displayed. Unless the search text box is displayed, user will not be able to enter any text to it.
Selenium provides a way of waiting until an element is present before carrying out an action on it.
1) In the SeleniunHelper.cs class, implement the following method.
This method will check an element is displayed in UI for a configured time period. If element is not displayed within given time frame, method will throw an exception.
Use the method in page object class as following.
Then call the implemented method in step class to check whether element is displayed or not before proceeding to next step.
Similarly, selenium provides many ways of implementing assertions as per requirement.
Use the method in page object class as following.
Then call the implemented method in step class to check whether element is displayed or not before proceeding to next step.
Similarly, selenium provides many ways of implementing assertions as per requirement.
No comments:
Post a Comment