Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def assert_screenshot_page_element(self, filename, threshold=0, exclude_elements=[], force=False):
VisualTest(self.driver_wrapper, force).assert_screenshot(self.web_element, filename, file_suffix,
threshold, exclude_elements)
def assert_screenshot(self, element, filename, threshold=0, exclude_elements=[], driver_wrapper=None, force=False):
"""Assert that a screenshot of an element is the same as a screenshot on disk, within a given threshold.
:param element: either a WebElement, PageElement or element locator as a tuple (locator_type, locator_value).
If None, a full screenshot is taken.
:param filename: the filename for the screenshot, which will be appended with ``.png``
:param threshold: percentage threshold for triggering a test failure (value between 0 and 1)
:param exclude_elements: list of CSS/XPATH selectors as a string or WebElement objects that must be excluded
from the assertion.
:param driver_wrapper: driver wrapper instance
:param force: if True, the screenshot is compared even if visual testing is disabled by configuration
"""
file_suffix = self.get_method_name()
VisualTest(driver_wrapper, force).assert_screenshot(element, filename, file_suffix, threshold, exclude_elements)
def assert_full_screenshot(self, filename, threshold=0, exclude_elements=[], driver_wrapper=None, force=False):
"""Assert that a driver screenshot is the same as a screenshot on disk, within a given threshold.
:param filename: the filename for the screenshot, which will be appended with ``.png``
:param threshold: percentage threshold for triggering a test failure (value between 0 and 1)
:param exclude_elements: list of CSS/XPATH selectors as a string or WebElement objects that must be excluded
from the assertion.
:param driver_wrapper: driver wrapper instance
:param force: if True, the screenshot is compared even if visual testing is disabled by configuration
"""
file_suffix = self.get_method_name()
VisualTest(driver_wrapper, force).assert_screenshot(None, filename, file_suffix, threshold, exclude_elements)
def assert_screenshot(element_or_selector, filename, threshold=0, exclude_elements=[], driver_wrapper=None,
force=False):
VisualTest(driver_wrapper, force).assert_screenshot(element_or_selector, filename, file_suffix, threshold,
exclude_elements)
def assert_screenshot_page_element(self, filename, threshold=0, exclude_elements=[], force=False):
VisualTest(self.driver_wrapper, force).assert_screenshot(self.web_element, filename, file_suffix, threshold,
exclude_elements)
def assert_screenshot(self, filename, threshold=0, exclude_elements=[], force=False):
"""Assert that a screenshot of the element is the same as a screenshot on disk, within a given threshold.
:param filename: the filename for the screenshot, which will be appended with ``.png``
:param threshold: percentage threshold for triggering a test failure (value between 0 and 1)
:param exclude_elements: list of WebElements, PageElements or element locators as a tuple (locator_type,
locator_value) that must be excluded from the assertion
:param force: if True, the screenshot is compared even if visual testing is disabled by configuration
"""
VisualTest(self.driver_wrapper, force).assert_screenshot(self.web_element, filename, self.__class__.__name__,
threshold, exclude_elements)
def assert_full_screenshot(filename, threshold=0, exclude_elements=[], driver_wrapper=None, force=False):
VisualTest(driver_wrapper, force).assert_screenshot(None, filename, file_suffix, threshold, exclude_elements)