com.applitools.eyes.selenium.fluent.SimpleRegionByElement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eyes-selenium-java4 Show documentation
Show all versions of eyes-selenium-java4 Show documentation
Applitools Eyes SDK for Selenium Java WebDriver
The newest version!
package com.applitools.eyes.selenium.fluent;
import com.applitools.eyes.*;
import com.applitools.eyes.fluent.GetRegion;
import com.applitools.eyes.selenium.Eyes;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
import java.util.ArrayList;
import java.util.List;
public class SimpleRegionByElement implements GetRegion {
protected WebElement element;
public SimpleRegionByElement(WebElement element) {
this.element = element;
}
@Override
public List getRegions(EyesBase eyesBase, EyesScreenshot screenshot, boolean adjustLocation) {
Point locationAsPoint = element.getLocation();
Dimension size = element.getSize();
// Element's coordinates are context relative, so we need to convert them first.
Location adjustedLocation = screenshot.getLocationInScreenshot(new Location(locationAsPoint.getX(), locationAsPoint.getY()),
((Eyes)eyesBase).getElementOriginalLocation(element),
CoordinatesType.CONTEXT_RELATIVE);
List value = new ArrayList<>();
value.add(new Region(adjustedLocation, new RectangleSize(size.getWidth(), size.getHeight()),
CoordinatesType.SCREENSHOT_AS_IS));
return value;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy