io.magentys.cinnamon.webdriver.conditions.ElementConditions Maven / Gradle / Ivy
package io.magentys.cinnamon.webdriver.conditions;
import io.magentys.cinnamon.webdriver.actions.synthetic.DomEvent;
import io.magentys.cinnamon.webdriver.elements.*;
import org.openqa.selenium.WebElement;
import static io.magentys.cinnamon.webdriver.conditions.Conditions.not;
public final class ElementConditions {
// Suppresses default constructor, ensuring non-instantiability.
private ElementConditions() {
}
public static Condition displayed = new DisplayedCondition();
public static Condition hidden = not(displayed);
public static Condition empty = new EmptyCondition();
public static Condition notEmpty = not(empty);
public static Condition enabled = new EnabledCondition();
public static Condition disabled = not(enabled);
public static Condition inViewPort = new InViewPortCondition();
public static Condition obscured = new ObscuredCondition();
public static Condition notObscured = not(obscured);
public static Condition selected = new SelectedCondition();
public static Condition deselected = not(selected);
public static Condition clickable = new AndCondition<>(displayed, enabled, notObscured);
public static Condition present = new Condition() {
@Override
public boolean apply(final WebElement element) {
return null != element;
}
@Override
public String toString() {
return "present";
}
};
public static Condition attributeContains(final String attribute, final String value) {
return new AttributeContainsCondition(attribute, value);
}
public static Condition attributeEquals(final String attribute, final String value) {
return new AttributeEqualsCondition(attribute, value);
}
public static Condition attributeMatches(final String attribute, final String regex) {
return new AttributeMatchesCondition(attribute, regex);
}
public static Condition attributeMatches(final String attribute, final String regex, final int flags) {
return new AttributeMatchesCondition(attribute, regex, flags);
}
public static Condition cssPropertyContains(final String cssProperty, final String value) {
return new CssPropertyContainsCondition(cssProperty, value);
}
public static Condition cssPropertyEquals(final String cssProperty, final String value) {
return new CssPropertyEqualsCondition(cssProperty, value);
}
public static Condition cssPropertyMatches(final String cssProperty, final String regex) {
return new CssPropertyMatchesCondition(cssProperty, regex);
}
public static Condition cssPropertyMatches(final String cssProperty, final String regex, final int flags) {
return new CssPropertyMatchesCondition(cssProperty, regex, flags);
}
public static Condition eventListenerRegistered(final DomEvent event) {
return new EventListenerRegisteredCondition(event);
}
public static Condition innerHtmlContains(final String text) {
return new InnerHtmlContainsCondition(text);
}
public static Condition innerHtmlContainsIgnoreCase(final String text) {
return new InnerHtmlContainsCondition(true, text);
}
public static Condition positionUnchanged(final long delayIntervalMillis) {
return new PositionUnchangedCondition(delayIntervalMillis);
}
public static Condition textContains(final String... text) {
return new TextContainsCondition(text);
}
public static Condition textContainsIgnoreCase(final String... text) {
return new TextContainsCondition(true, text);
}
public static Condition textEquals(final String text) {
return new TextEqualsCondition(text);
}
public static Condition textEqualsIgnoreCase(final String text, final boolean ignoreCase) {
return new TextEqualsCondition(true, text);
}
public static Condition textMatches(final String text) {
return new TextMatchesCondition(text);
}
public static Condition textMatches(final String text, final int flags) {
return new TextMatchesCondition(flags, text);
}
}