// Path: webdriver-matchers/src/main/java/ru/yandex/qatools/matchers/webdriver/driver/CanFindElementMatcher.java
// @Factory
// public static Matcher<WebDriver> canFindElement(By by) {
//     return new CanFindElementMatcher(by);
// }


import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static ru.yandex.qatools.matchers.webdriver.driver.CanFindElementMatcher.canFindElement;
package ru.yandex.qatools.matchers.webdriver.driver;



public class CanFindElementMatcherTest {

    public static final By XPATH_EXISTS = By.xpath("//a");
    public static final By XPATH_NOT_EXISTS = By.xpath("//aa");

    @Test
    public void worksPositive() {
        WebDriver driver = mock(WebDriver.class);
        WebElement element = mock(WebElement.class);

        when(driver.findElement(XPATH_EXISTS)).thenReturn(element);

// Path: webdriver-matchers/src/main/java/ru/yandex/qatools/matchers/webdriver/driver/CanFindElementMatcher.java
// @Factory
// public static Matcher<WebDriver> canFindElement(By by) {
//     return new CanFindElementMatcher(by);
// }


// Path: webdriver-matchers/src/test/java/ru/yandex/qatools/matchers/webdriver/driver/CanFindElementMatcherTest.java
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static ru.yandex.qatools.matchers.webdriver.driver.CanFindElementMatcher.canFindElement;

package ru.yandex.qatools.matchers.webdriver.driver;



public class CanFindElementMatcherTest {

    public static final By XPATH_EXISTS = By.xpath("//a");
    public static final By XPATH_NOT_EXISTS = By.xpath("//aa");

    @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));