All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.serenitybdd.screenplay.matchers.statematchers.ContainsTextMatcher Maven / Gradle / Ivy

There is a newer version: 4.2.8
Show newest version
package net.serenitybdd.screenplay.matchers.statematchers;

import net.serenitybdd.core.pages.WebElementState;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;

public class ContainsTextMatcher extends TypeSafeMatcher {

    private final String expectedText;

    public ContainsTextMatcher(String expectedText) {
        this.expectedText = expectedText;
    }

    @Override
    protected boolean matchesSafely(T element) {
        return element.containsText(expectedText);
    }

    @Override
    public void describeTo(Description description) {
        description.appendText("an element containing '").appendText(expectedText).appendText("'");
    }

    @Override
    protected void describeMismatchSafely(T item, Description mismatchDescription) {
        mismatchDescription.appendText(" was ").appendText(WebElementStateDescription.forElement(item));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy