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

ru.yandex.qatools.ashot.coordinates.CoordsProvider Maven / Gradle / Ivy

There is a newer version: 1.5.4
Show newest version
package ru.yandex.qatools.ashot.coordinates;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.io.Serializable;
import java.util.*;

/**
 * @author Pavel Zorin
 */

public abstract class CoordsProvider implements Serializable {

    public abstract Coords ofElement(WebDriver driver, WebElement element);

    public Set ofElements(WebDriver driver, Iterable elements) {
        Set elementsCoords = new HashSet<>();
        for (WebElement element : elements) {
            Coords elementCoords = ofElement(driver, element);
            if (!elementCoords.isEmpty()) {
                elementsCoords.add(ofElement(driver, element));
            }
        }
        return elementsCoords;
    }

    @SuppressWarnings("UnusedDeclaration")
    public Set ofElements(WebDriver driver, WebElement... elements) {
        return ofElements(driver, Arrays.asList(elements));
    }

    @SuppressWarnings("UnusedDeclaration")
    public Set locatedBy(WebDriver driver, By locator) {
        return ofElements(driver, driver.findElements(locator));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy