The third publication from the Design & Architecture Series is going to be dedicated to the creation of Hybrid Test Framework Controls and their Selenium WebDriver implementation. First, I am going to show you how to create several controls' interfaces that will be part of the Hybrid Test Framework Core project. After that, I am going to guide you through the process of their concrete implementation via Selenium WebDriver. Finally, you will see a fully working test example.

Hybrid Test Framework Controls IContentElement Interface

This is the interface for all elements that can have an inner text. You can get their text through the Content property and Hover on them. ContentElement Selenium Driver Implementation

The concrete Selenium Driver implementation inherits from the Element base class. You can find its code in my previous article Create Hybrid Test Automation Framework - Selenium Driver Implementation. Also, to be able to use the control in the hybrid mode, we need to implement the IContentElement interface.To get the text of the WebDriver element, we use the Text property of the IWebElement interface. To simulate hover over the item we use the Selenium Actions class. IAnchor Interface

The only particular part of the interface is the Url property. Anchor Selenium Driver Implementation

The Anchor class inherits from the ContentElement base class instead from the Element class. We use the GetAttribute IWebElement's method to get the HREF of the item. ICheckbox Interface

Checkbox Selenium Driver Implementation

We can use the Selected property of the IWebElement interface to find out if the checkbox is checked. To check or uncheck the item we just use the Click method. It is possible to have only a single Check method with a boolean parameter carrying the information for the check status. IComboBox Interface

Through the SelectedValue property, we get a string representation of the currently selected item. SelectValue method selects an option by its text value. If we need, we can add more variations of this method (select by index). ComboBox Selenium Driver Implementation

The pure WebDriver doesn't provide an easy way to work with comboBoxes. However, we use the SelectElement wrapper, part of the Selenium.Support NuGet. Through its SelectedOption property, we can get the currently selected item. Also, it provides a couple of different methods to select options. You can read more about it in my article- Getting Started with WebDriver C# in 10 Minutes. ITextBox Interface

To simplify the API, we can get or set the text box's text though the Text property. Also, you can check if the item is disabled or enabled via the IsEnabled property. The Focus method is identical to Hover. TextBox Selenium Driver Implementation

To get the text of the text box, we can use again the GetAttribute method but this time we get the value attribute. The Focus method's implementation is identical to the one of the Hover method. IDiv Interface

Div Selenium Driver Implementation

The Div element is nothing more than a content element. However, to be able to use it in a hybrid manner we need to have a separate class. IKendoGrid Interface

Sometimes there are more complex controls such as the Kendo Grid. The interface contains the most common usages of the control wrapped as C# methods. KendoGrid Selenium Driver Implementation

You can read a lot more in my dedicated article- Automate Kendo Grid with WebDriver and JavaScript. Hybrid Test Framework Controls in Test Page Object

Here there is nothing different compared to the examples from the previous articles. We just pass the IElementFinder and INavigationService interfaces to the constructor of the base page class. You can read more about this type of page objects in my dedicated article- Page Objects That Make Code More Maintainable. Page Object Map

The most interesting part is situated here. All properties do not return the WebDriver's IWebElement interface. To support different driver's implementations, the page object map now uses the different hybrid test framework's interfaces. Their concrete implementation will be resolved at runtime through Unity IoC container. Page Object Asserter

Test Example