def location_in_screenshot(self, location, coordinates_type):
     location = self.convert_location(location, coordinates_type,
                                      self.SCREENSHOT_AS_IS)
     # Making sure it's within the screenshot bounds
     if not self.frame_window.contains(location):
         raise OutOfBoundsError(
             "Location %s ('%s') is not visible in screenshot!" %
             (location, coordinates_type))
     return location
Exemplo n.º 2
0
 def sub_screenshot(self, region, throw_if_clipped=False):
     # type: (Region, bool) -> EyesWebDriverScreenshot
     # We calculate intersection based on as-is coordinates.
     as_is_sub_screenshot_region = self.intersected_region(
         region, self.SCREENSHOT_AS_IS)
     if (as_is_sub_screenshot_region.is_size_empty or throw_if_clipped
             and as_is_sub_screenshot_region.size != region.size):
         raise OutOfBoundsError(
             "Region [%s] is out of screenshot bounds [%s]" %
             (region, self.frame_window))
     sub_image = image_utils.get_image_part(self.image,
                                            as_is_sub_screenshot_region)
     return EyesWebDriverScreenshot.from_screenshot(
         self._driver,
         sub_image,
         Region(region.left, region.top, sub_image.width, sub_image.height),
         self._frame_location_in_screenshot,
     )