### Question:
CanFindElementMatcher extends TypeSafeMatcher<WebDriver> { @Factory public static Matcher<WebDriver> canFindElement(By by) { return new CanFindElementMatcher(by); } protected  CanFindElementMatcher(By by); @Override void describeTo(Description description); @Factory static Matcher<WebDriver> canFindElement(By by);  }### Answer:
@Test public void worksPositive() { WebDriver driver = mock(WebDriver.class); WebElement element = mock(WebElement.class); when(driver.findElement(XPATH_EXISTS)).thenReturn(element); assertThat("Element should be found", driver, canFindElement(XPATH_EXISTS)); }
@Test public void worksNegative() { WebDriver driver = mock(WebDriver.class); when(driver.findElement(XPATH_NOT_EXISTS)).thenThrow(new NoSuchElementException("")); assertThat("Element should not be found", driver, not(canFindElement(XPATH_NOT_EXISTS))); }