APIΒΆ
- ScreenShot(object):
- get_screen(self, url = None):
Get specified screen(s)
Parameters: url (string) – web page to capture (including http protocol, None to reuse loaded webpage) Returns: Screen shot Return type: ImageContainer Raises: Exception
- close(self):
Close driver
- ImageContainer(object):
Container for an image.
Possible positions:
- MIDDLE
- INSIDE
- OUTSIDE
- BORDER
- LEFT
- RIGHT
- TOP
- BOTTOM
Example of usage:
position = Position.OUTSIDE | Position.LEFT
- cut_element(self, id = None, xpath = None):
Cut one element by id or xpath. After this operation you cannot cut more elements.
Parameters: - id (string) – id of a given element
- xpath (string) – xpath of a given element
Returns: ImageContainer
Return type: ImageContainer
Raises: RuntimeError, ValueError
- cut_area(self, x = 0, y = 0, height = None, width = None):
Cut area from a given point to a given size (in px)
Parameters: - x (integer) – x coordinate for a point
- y (integer) – y coordinate for a point
- height (integer or None) – height of an area
- width (integer or None) – width of an area
Returns: ImageContainer
Return type: ImageContainer
- draw_dot(self, id = None, xpath = None, coordinates = None, padding = 0, color = None, size = None):
- For id and xpath:
- Draw a red dot on a given position of a given element.
- For coordinates:
- Draw a red dot in a given point (x, y)
Parameters: - id (string) – id of a given element
- xpath (string) – xpath of a given element
- coordinates (tuple of integers (x, y)) – coordinates = (x, y) - center of a dot
- position (Position enum) – position of a dot
- padding (tuple of integers (x, y)) – padding between dot and element
- color (color object or string) – color of dot
- size (integer) – size of dot
Returns: ImageContainer
Return type: ImageContainer
Raises: ValueError
- draw_frame(self, id = None, xpath = None, coordinates = None, padding = None, color = None, size = None):
- For id and xpath:
- Draw a frame around a given element
- For coordinates:
- Draw a frame for a given coordinates
Parameters: - id (string) – id of a given element
- xpath (string) – xpath of a given element
- coordinates (tuple of integers - (x, y, width, height)) – coordinates for a frame - coordinates = (x, y, width, height) - middle of a dot
- padding (tuple of integers (x, y)) – padding between frame and element
- color (color object or string) – color of a frame (see PIL’s documentation)
- size (integer) – size of frame (thickness)
Returns: ImageContainer
Return type: ImageContainer
Raises: ValueError
- draw_image(self, id = None, xpath = None, coordinates = None, position = Position.MIDDLE, padding = (0, 0), filename = None, image = None):
- For id and xpath:
- Draw an image on a given position of a given element.
- For coordinates:
- Draw an image in a given point (x, y)
Parameters: - id (string) – id of a given element
- xpath (string) – xpath of a given element
- coordinates (tuple of integers (x, y)) – coordinates = (x, y) - center of an image
- position (Position enum) – position of an image
- padding (tuple of integers (x, y)) – padding between dot and element
- filename (string) – filename of the image file
- image (Image object) – reference to Image object
Returns: ImageContainer
Return type: ImageContainer
Raises: ValueError
- draw_zoom(self, id = None, xpath = None, coordinates = None, position = Position.MIDDLE, padding = (0, 0), zoom = None):
- For id and xpath:
- Draw a zoomed image on a given position of a given element.
- For coordinates:
- Draw a zoomed element in a given point (x, y).
Parameters: - id (string) – id of a given element
- xpath (string) – xpath of a given element
- coordinates (tuple of integers (x, y)) – coordinates = (x, y) - center of a zoomed image
- position (Position enum) – position of a zoomed image
- padding (tuple of integers (x, y)) – padding between dot and element
- zoom (integer) – zoom size of an element
Returns: ImageContainer
Return type: ImageContainer
- draw_blur(self, id = None, xpath = None):
Blur whole area of the screenshot except a given element.
Parameters: - id (string) – id of a given element
- xpath (string) – xpath of a given element
Returns: ImageContainer
Return type: ImageContainer
Raises: RuntimeError, ValueError
- save(self, filename):
Save to a filename
Parameters: filename (string) – name of a file Returns: ImageContainer Return type: ImageContainer
- is_cut(self):
If True, then there is possibility to cut an element. If False, then there is not possibility to cut any element.
Returns: possibility to cut Return type: boolean