New to C#, started learning in order to do test automation using Selenium C# with MS Visual Studio. Currently a manual tester.
I've been building a testing framework using TDD and the POM pattern. I'm still in the very early stages. I have about a dozen classes so far in 2 projects, the one project is dedicated to webdrivers with a single class called WebDriverFactory, the other project is broken into several folders where I have page classes, test classes, and a new folder I'm working on where there will be universal elements.
The application I'm automating has SO many elements which are on many different pages using the exact same selector and functioning in the exact same way. Also, there are many forms, selection boxes, inputs, etc., which use different locators, but behave in the exact same way - so I started to make a universal locators class and a universal methods class. The Locators class might be divided into several classes depending on arrangement on the pages or type of element. The Methods class will have methods which take the iwebelement locators and a variables to enter as arguments.
Here's an test method which currently runs and passes. I'm in the middle of refactoring it, using it as a guinea pig. As you can see, it uses a method from the Batches class to search for a provider, and then verifies that the correct provider is pulled using a method from the universal search methods class. Once I finish refactoring, it won't use the Batches class's method to search for a provider, but will also use a universal search class's method: because that style of search field is used a dozen times on each of a dozen pages for different search parameters... and there are several different styles of search fields as well...
[TestMethod]
[Description("Search by a single Provider and verify results match")]
public void SingleProviderSearch()
{
var searchResultsActions = new SearchResultsActions(Driver);
var searchResultsLocators = new SearchResultsLocators(Driver);
var batches = new Batches(Driver);
string provider = "Geisinger Medical Center";
batches.GoTo();
batches.EnterProvider(provider);
batches.Search();
//var batchesResults = new BatchesResults(Driver);
//Assert.IsTrue(batchesResults.VerifyAllProvidersOfResults(provider), "The Provider column didn't match the searched-for Provider");
Assert.IsTrue(searchResultsActions.VerifyTableColumn(provider, searchResultsLocators.ProviderColumn), "The Provider column didn't match the searched-for Provider");
// Confirm Fails
//Assert.IsTrue(batchesResults.VerifyAllProvidersOfResults("test"), "The Provider column didn't match the searched-for Provider");
How can I stick to the POM, when such a huge portion of the functionality is universal across the application? Don't get me wrong - there's unique stuff too.
One of the ideas I had was, which you see the beginnings of above, was to create a universal locators class which inherits from my base application class, then create a universal methods class which inherits from the universal locators class, then create the specific pages classes which inherit from the universal methods class.
Does that sound like a decent idea which will adhere to good design principles? It's the best compromise I've been able to come up with to balance DRY and POM.
So the question is: since I don't have programming experience, is the design pattern i've illustrated above, using a combination of POM but with a couple huge universal classes, feasible? Or is there another design pattern which would match the application better?
In order not to get this question closed - i'm not asking for opinions on that is the best, but simple practical ideas and solutions to overcome this design problem. Thanks!