Early on in my career I came across a post describing a development pattern that was ideal for APIs, but after reading it I realized that it was better for test automation.
The pattern is called the Fluent Pattern, not to be confused with Microsoft’s Fluent Design. The Fluent Pattern is comprised of method chaining and method cascading.
By doing this your test code will be something like this:
Method chaining is being able to chain method calls within a class. This is done with every method returning an instance of a class. For the most part this is done by
return this; for each of the methods in a class. The best use case is having a set of methods that are used to
I know this part is somewhat confusing since you can not have a method return a string or boolean and within your current code base it may require some work arounds on how you approach some aspects, but the benefits are awesome.
Method cascading is having the method return a new object.
This blog is new, this post will be updated before Selenium Conference Chicago starts.
Essentially you want to make sure that every method returns something that you can work with.