ru.yandex.qatools.ashot.coordinates.CoordsProvider Maven / Gradle / Ivy
The 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(elementCoords);
}
}
return Collections.unmodifiableSet(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));
}
}