### Question:
PageAssert extends AbstractAssert<PageAssert, FluentPage> implements PageStateAssert { @Override public PageAssert hasTitle(String title) { try { String pageTitle = actual.getDriver().getTitle(); if (!pageTitle.equals(title)) { failWithMessage("Current page title is " + pageTitle + ". Expected " + title); } } catch (NullPointerException e) { failWithMessage("Current page has no title"); } return this; } PageAssert(FluentPage actual); @Override PageAssert hasElement(FluentWebElement element); @Override PageAssert hasElements(FluentList<? extends FluentWebElement> fluentList); @Override PageAssert hasElementDisplayed(FluentWebElement element); @Override PageAssert hasTitle(String title); @Override PageAssert hasUrl(String url); @Override PageAssert hasPageSourceContaining(String value); @Override PageAssert hasExpectedUrl(); @Override PageAssert hasExpectedElements(); @Deprecated @Override PageAssert isAt();  }### Answer:
@Test public void hasTitleOk() { String title = "title"; doReturn(title).when(driver).getTitle(); pageAssert.hasTitle(title); }
@Test public void hasTitleKo() { doReturn("title").when(driver).getTitle(); assertThatAssertionErrorIsThrownBy(() -> pageAssert.hasTitle("wrong")) .hasMessage("Current page title is title. Expected wrong"); }
@Test public void hasTitleShouldFailDueToNullPointerException() { doReturn(null).when(fluentPage).getDriver(); assertThatAssertionErrorIsThrownBy(() -> pageAssert.hasTitle("non-existent")) .hasMessage("Current page has no title"); }