SimpleCore graphical helper extensions.

GraphicalExtensions#

class GraphicalExtensions()

Collection of graphical helper functions.

take#

@staticmethod
def take(testcase)

Take a screenshot and copy it on the host.

Arguments:

  • testcase - reference to the testcase instance

take_background#

@staticmethod
def take_background(testcase, command)

Take a screenshot when something is running and copy it on the host.

Arguments:

  • testcase - reference to the testcase instance

crop#

@staticmethod
def crop(testcase, screenshot, width=0, height=0, x=0, y=0)

Crop a screenshot at the size given by width, height, x and y.

Arguments:

screenshot : name of the screenshot which is to be compared

  • width - width of the cropped image

  • height - height of the cropped image

  • x - abscissa of the cropped image

  • y - ordinate of the cropped image

Returns:

  • screenshot_cropped - name of the cropped screenshot

get_bbox_from_color#

@staticmethod
def get_bbox_from_color(testcase,
                        screenshot,
                        size,
                        color=(255, 255, 255),
                        gray=0,
                        fuzzval=None)

Use a color to get the border of a subsection of the screenshot.

Arguments:

screenshot : name of the screenshot which is to be compared

  • color - tuple of the color to use as a border

Returns:

  • Tuple - (width, height, x, y)

compare#

@staticmethod
def compare(testcase, image_ref, screenshot)

Take a screenshot and compare its hash to the hash of a reference image.

Arguments:

  • image_ref - path to the reference image screenshot : name of the screenshot which is to be compared

Returns:

  • Tuple - (phash, base64 encoded screenshot)

remove#

@staticmethod
def remove(screenshot)

Remove the screenshot on the host.

Arguments:

screenshot : name of the screenshot to remove