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

com.epam.jdi.light.asserts.ListAssert Maven / Gradle / Ivy

There is a newer version: 1.6.0
Show newest version
package com.epam.jdi.light.asserts;

import com.epam.jdi.light.elements.base.UIElement;
import org.hamcrest.Matcher;
import org.openqa.selenium.WebElement;

import java.util.Collection;
import java.util.List;

import static com.epam.jdi.tools.LinqUtils.map;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;

public class ListAssert {
    List elements;

    public ListAssert(List elements) {
        this.elements = map(elements, el -> new UIElement().setWebElement(el));
    }

    public void texts(Matcher> condition) {
        assertThat(map(elements, WebElement::getText), condition);
    }
    public void attrs(String attrName, Matcher> condition) {
        assertThat(map(elements, el -> el.getAttribute(attrName)), condition);
    }
    public void css(String css, Matcher> condition) {
        assertThat(map(elements, el -> el.getCssValue(css)), condition);
    }
    public void tags(Matcher> condition) {
        assertThat(map(elements, WebElement::getTagName), condition);
    }
    public void cssClasses(Matcher> condition) {
        assertThat(map(elements, el -> el.getAttribute("class")), condition);
    }
    public void allDisplayed() {
        assertThat(map(elements, UIElement::isDisplayed), everyItem(is(true)));
    }
    public void displayed() {
        assertThat(map(elements, UIElement::isDisplayed), hasItem(true));
    }
    public void hidden() {
        assertThat(map(elements, UIElement::isDisplayed), everyItem(is(false)));
    }
    public void selected(Matcher> condition) {
        assertThat(map(elements, UIElement::isSelected), condition);
    }
    public void enabled(Matcher> condition) {
        assertThat(map(elements, UIElement::isEnabled), condition);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy