/** * Get the intersection of the given region with the screenshot. * * @param region The region to intersect. * @param coordinatesType The coordinates type of {@code region}. * @return The intersected region, in {@code coordinatesType} coordinates. */ protected Region getIntersectedRegion(Region region, CoordinatesType coordinatesType) { return getIntersectedRegion(region, coordinatesType, coordinatesType); }
@Override protected EyesScreenshot getSubScreenshot(EyesScreenshot screenshot, Region region, ICheckSettingsInternal checkSettingsInternal) { ISeleniumCheckTarget seleniumCheckTarget = (checkSettingsInternal instanceof ISeleniumCheckTarget) ? (ISeleniumCheckTarget) checkSettingsInternal : null; logger.verbose("original region: " + region); region = regionPositionCompensation.compensateRegionPosition(region, devicePixelRatio); logger.verbose("compensated region: " + region); if (seleniumCheckTarget == null) { // we should't get here, but just in case return screenshot.getSubScreenshot(region, false); } // For check frame continue as usual if (seleniumCheckTarget.getFrameChain().size() > 0) { return screenshot.getSubScreenshot(region, false); } // For check region, we want the screenshot window to know it's a region. return ((EyesWebDriverScreenshot) screenshot).getSubScreenshotForRegion(region, false); }
cursorInScreenshot = lastScreenshot.getLocationInScreenshot( cursorInScreenshot, CoordinatesType.CONTEXT_RELATIVE); } catch (OutOfBoundsException e) { lastScreenshot.getIntersectedRegion(control, CoordinatesType.CONTEXT_RELATIVE, CoordinatesType.SCREENSHOT_AS_IS);
@Override public List<Region> getRegions(EyesBase eyesBase, EyesScreenshot screenshot, boolean adjustLocation) { Point locationAsPoint = element.getLocation(); Dimension size = element.getSize(); Location adjustedLocation; if (screenshot != null) { // Element's coordinates are context relative, so we need to convert them first. adjustedLocation = screenshot.getLocationInScreenshot(new Location(locationAsPoint.getX(), locationAsPoint.getY()), CoordinatesType.CONTEXT_RELATIVE); } else { adjustedLocation = new Location(locationAsPoint.getX(), locationAsPoint.getY()); } List<Region> value = new ArrayList<>(); value.add(new Region(adjustedLocation, new RectangleSize(size.getWidth(), size.getHeight()), CoordinatesType.SCREENSHOT_AS_IS)); return value; } }
/** * Converts a region's location coordinates with the {@code from} * coordinates type to the {@code to} coordinates type. * * @param region The region which location's coordinates needs to be * converted. * @param from The current coordinates type for {@code region}. * @param to The target coordinates type for {@code region}. * @return A new region which is the transformation of {@code region} to * the {@code to} coordinates type. */ protected Region convertRegionLocation(Region region, CoordinatesType from, CoordinatesType to) { ArgumentGuard.notNull(region, "region"); if (region.isEmpty()) { return new Region(region); } ArgumentGuard.notNull(from, "from"); ArgumentGuard.notNull(to, "to"); Location updatedLocation = convertLocation(region.getLocation(), from, to); return new Region(updatedLocation, region.getSize()); } }
cursorInScreenshot = lastScreenshot.getLocationInScreenshot( cursorInScreenshot, CoordinatesType.CONTEXT_RELATIVE); } catch (OutOfBoundsException e) { lastScreenshot.getIntersectedRegion(control, CoordinatesType.CONTEXT_RELATIVE, CoordinatesType.SCREENSHOT_AS_IS);
@Override public List<FloatingMatchSettings> getRegions(EyesBase eyesBase, EyesScreenshot screenshot) { Point locationAsPoint = element.getLocation(); Dimension size = element.getSize(); Location adjustedLocation; if (screenshot != null) { // Element's coordinates are context relative, so we need to convert them first. adjustedLocation = screenshot.getLocationInScreenshot(new Location(locationAsPoint.getX(), locationAsPoint.getY()), CoordinatesType.CONTEXT_RELATIVE); } else { adjustedLocation = new Location(locationAsPoint.getX(), locationAsPoint.getY()); } List<FloatingMatchSettings> value = new ArrayList<>(); value.add(new FloatingMatchSettings(adjustedLocation.getX(), adjustedLocation.getY(), size.getWidth(), size.getHeight(), maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset)); return value; } }
/** * Converts a region's location coordinates with the {@code from} * coordinates type to the {@code to} coordinates type. * @param region The region which location's coordinates needs to be converted. * @param from The current coordinates type for {@code region}. * @param to The target coordinates type for {@code region}. * @return A new region which is the transformation of {@code region} to * the {@code to} coordinates type. */ public Region convertRegionLocation(Region region, CoordinatesType from, CoordinatesType to) { ArgumentGuard.notNull(region, "region"); if (region.isSizeEmpty()) { return new Region(region); } ArgumentGuard.notNull(from, "from"); ArgumentGuard.notNull(to, "to"); Location originalLocation = region.getLocation(); logger.verbose("original location: " + originalLocation); Location updatedLocation = convertLocation(originalLocation, from, to); logger.verbose("updated location: " + updatedLocation); return new Region(updatedLocation, region.getSize()); } }
cursorInScreenshot = lastScreenshot.getLocationInScreenshot( cursorInScreenshot, CoordinatesType.CONTEXT_RELATIVE); } catch (OutOfBoundsException e) { lastScreenshot.getIntersectedRegion(control, CoordinatesType.CONTEXT_RELATIVE, CoordinatesType.SCREENSHOT_AS_IS);
control = lastScreenshot.getIntersectedRegion(control, CoordinatesType.CONTEXT_RELATIVE, CoordinatesType.SCREENSHOT_AS_IS);
@Override public List<Region> getRegions(EyesBase eyesBase, EyesScreenshot screenshot, boolean adjustLocation) { List<WebElement> elements = ((Eyes) eyesBase).getDriver().findElements(this.selector); List<Region> values = new ArrayList<>(elements.size()); for (WebElement element : elements) { Point locationAsPoint = element.getLocation(); Dimension size = element.getSize(); Location adjustedLocation; if (screenshot != null) { // Element's coordinates are context relative, so we need to convert them first. adjustedLocation = screenshot.getLocationInScreenshot( new Location(locationAsPoint.getX(), locationAsPoint.getY()), CoordinatesType.CONTEXT_RELATIVE); } else { adjustedLocation = new Location(locationAsPoint.getX(), locationAsPoint.getY()); } values.add(new Region(adjustedLocation, new RectangleSize(size.getWidth(), size.getHeight()), CoordinatesType.SCREENSHOT_AS_IS)); } return values; } }
screenshot = screenshot.getSubScreenshot(region, regionProvider.getCoordinatesType(), false);
/** * Converts a region's location coordinates with the {@code from} * coordinates type to the {@code to} coordinates type. * @param region The region which location's coordinates needs to be converted. * @param from The current coordinates type for {@code region}. * @param to The target coordinates type for {@code region}. * @return A new region which is the transformation of {@code region} to * the {@code to} coordinates type. */ public Region convertRegionLocation(Region region, CoordinatesType from, CoordinatesType to) { ArgumentGuard.notNull(region, "region"); if (region.isSizeEmpty()) { return new Region(region); } ArgumentGuard.notNull(from, "from"); ArgumentGuard.notNull(to, "to"); Location originalLocation = region.getLocation(); logger.verbose("original location: " + originalLocation); Location updatedLocation = convertLocation(originalLocation, from, to); logger.verbose("updated location: " + updatedLocation); return new Region(updatedLocation, region.getSize()); } }
control = lastScreenshot.getIntersectedRegion(control, CoordinatesType.CONTEXT_RELATIVE, CoordinatesType.SCREENSHOT_AS_IS);
@Override public List<FloatingMatchSettings> getRegions(EyesBase eyesBase, EyesScreenshot screenshot) { List<WebElement> elements = ((Eyes) eyesBase).getDriver().findElements(this.selector); List<FloatingMatchSettings> values = new ArrayList<>(); Logger logger = eyesBase.getLogger(); for (WebElement element : elements) { Point locationAsPoint = element.getLocation(); RectangleSize size = EyesSeleniumUtils.getElementVisibleSize(logger, element); Location adjustedLocation; if (screenshot != null) { // Element's coordinates are context relative, so we need to convert them first. adjustedLocation = screenshot.getLocationInScreenshot(new Location(locationAsPoint.getX(), locationAsPoint.getY()), CoordinatesType.CONTEXT_RELATIVE); } else { adjustedLocation = new Location(locationAsPoint.getX(), locationAsPoint.getY()); } values.add(new FloatingMatchSettings(adjustedLocation.getX(), adjustedLocation.getY(), size.getWidth(), size.getHeight(), maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset)); } return values; } }
screenshot = screenshot.getSubScreenshot(region, regionProvider.getCoordinatesType(), false);
control = lastScreenshot.getIntersectedRegion(control, CoordinatesType.CONTEXT_RELATIVE, CoordinatesType.SCREENSHOT_AS_IS);