Consider using a fluent API

Martin Fowler coined the term “Fluent API”. Selenium already implements something like this in their FluentWait class, which is meant as an alternative to the standard Wait class. You could enable the Fluent API design pattern in your page object and then query the Google search page with a code snippet like this one:

driver.get( "" );
GoogleSearchPage gsp = new GoogleSearchPage(driver);

The Google page object class with this fluent behavior might look like this:

public abstract class BasePage {
    protected WebDriver driver;

    public BasePage(WebDriver driver) {
        this.driver = driver;

public class GoogleSearchPage extends BasePage {
    public GoogleSearchPage(WebDriver driver) {
        // Generally do not assert within pages or components.
        // Effectively throws an exception if the lambda condition is not met.
        new WebDriverWait(driver, Duration.ofSeconds(3)).until(d -> d.findElement("logo")));

    public GoogleSearchPage setSearchString(String sstr) {
        return this;

    public void clickSearchButton() {