pdx Selenium & Test Automation Users Group Message Board › A page object using a "Fluent API" design pattern

A page object using a "Fluent API" design pattern

Jon A.
user 61898832
Portland, OR
Post #: 8
Martin Fowler coined the term "Fluent API" and I heard it would work well with Selenium2 WebDriver and so tonight I took a stab and creating a page object with a fluent API interface. Here is what I came up with. Feel free to fork my code and contribute your own version! :-)


Specifically, here is what a fluent page-object test might look like:

public void testFluentPageObject() {
GoogleSearchPage gs = new GoogleSearchPage();
.setSearchString("iphone app")
.waitForTime(3, 1000)
.selectItem( "development" )
.waitForTime(5, 1000)
.clickLogo( "gbqlt" ); //click Google logo
System.out.println("Done with fluent test.");
Jon A.
user 61898832
Portland, OR
Post #: 9
I fixed a few bugs and improved the fluent page object in my test project (see the previous link in this thread).

NOTE: The reason why I chose to use a non-object-oriented approach with a static WebDriver instance is because I needed the browser to remain open between unit tests: not sure how to do this otherwise since objects get cleaned up between tests (when you are running from Parameterized input).
Powered by mvnForum

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy