Example #1
0
def test_selenium_eyes_check_args_name_none_check_settings_valid(
        eyes_check_mock):
    eyes_check_mock.check(None, SeleniumCheckSettings().with_name("A"))

    assert eyes_check_mock.calls == [
        call(SeleniumCheckSettings().with_name("A"))
    ]
def test_floating_region_by_element(check_settings_keyword, web_element):
    res = SeleniumCheckSettings().floating(34, web_element)
    assert res == check_settings_keyword.floating_region_with_max_offset_by_element(
        34, web_element)
    res = SeleniumCheckSettings().floating(web_element, 20, 30, 40, 50)
    assert res == check_settings_keyword.floating_region_by_element(
        web_element, 20, 30, 40, 50)
def test_floating_region_by_selector(check_settings_keyword, css_selector,
                                     by_selector):
    res = SeleniumCheckSettings().floating(34, by_selector)
    assert res == check_settings_keyword.floating_region_with_max_offset_by_selector(
        34, css_selector)
    res = SeleniumCheckSettings().floating(by_selector, 20, 30, 40, 50)
    assert res == check_settings_keyword.floating_region_by_selector(
        css_selector, 20, 30, 40, 50)
def test_lazy_load_default_settings():
    cs = SeleniumCheckSettings()
    cs.lazy_load()

    assert cs.values.lazy_load is not None
    assert cs.values.lazy_load.scroll_length == 300
    assert cs.values.lazy_load.waiting_time == 2000
    assert cs.values.lazy_load.page_height == 15000
def test_floating_region_by_coordinates(check_settings_keyword):
    res = SeleniumCheckSettings().floating(34, Region(23, 44, 55, 66))
    assert res == check_settings_keyword.floating_region_with_max_offset_by_coordinates(
        34, "[23 44 55 66]")
    res = SeleniumCheckSettings().floating(Region(23, 44, 55, 66), 20, 30, 40,
                                           50)
    assert res == check_settings_keyword.floating_region_by_coordinates(
        "[23 44 55 66]", 20, 30, 40, 50)
def test_lazy_load_custom_settings():
    cs = SeleniumCheckSettings()
    cs.lazy_load(scroll_length=1, waiting_time=2, page_height=3)

    assert cs.values.lazy_load is not None
    assert cs.values.lazy_load.scroll_length == 1
    assert cs.values.lazy_load.waiting_time == 2
    assert cs.values.lazy_load.page_height == 3
def get_cs_from_method(method_name, *args, **kwargs):
    """
    Return initialized CheckSettings instance and invoked `method_name` with `args`

    Example ::

        cs = SeleniumCheckSettings().region(*args)
    """
    return getattr(SeleniumCheckSettings(), method_name)(*args, **kwargs)
    def _process_app_output(self, ocr_region):
        settings = SeleniumCheckSettings().fully()
        settings.values.ocr_region = ocr_region

        settings = settings.region(ocr_region.target)

        def app_output_callback(check_settings, region):
            if not check_settings.values.target_region:
                element = _element_from_check_settings(self._driver,
                                                       check_settings)
                ocr_region.hint = eyes_selenium_utils.get_inner_text(
                    self._driver, element)
            app_output = self._eyes._app_output_provider.get_app_output(
                region, self._eyes._last_screenshot, check_settings)
            ocr_region.app_output_with_screenshot = app_output

        ocr_region.add_process_app_output(app_output_callback)
        self._eyes.check(settings)
def test_disable_browser_fetching(check_settings_keyword):
    res = SeleniumCheckSettings().disable_browser_fetching()
    assert res == check_settings_keyword.disable_browser_fetching()
def test_timeout(check_settings_keyword):
    res = SeleniumCheckSettings().timeout(53)
    assert res == check_settings_keyword.timeout(53)
def test_layout_breakpoints(check_settings_keyword):
    res = SeleniumCheckSettings().layout_breakpoints(True)
    assert res == check_settings_keyword.enable_layout_breakpoints()
    res = SeleniumCheckSettings().layout_breakpoints(40, 50, 40, 60)
    assert res == check_settings_keyword.layout_breakpoints("40 50 40 60")
Example #12
0
def test_selenium_eyes_check_args_both_none(eyes_check_mock):
    eyes_check_mock.check(None, None)

    assert eyes_check_mock.calls == [call(SeleniumCheckSettings())]
def test_send_dom(check_settings_keyword):
    res = SeleniumCheckSettings().send_dom()
    assert res == check_settings_keyword.send_dom()
Example #14
0
def test_selenium_eyes_check_args_only_settings_keyword(eyes_check_mock):
    eyes_check_mock.check(check_settings=SeleniumCheckSettings())

    assert eyes_check_mock.calls == [call(SeleniumCheckSettings())]
def test_match_level(check_settings_keyword):
    res = SeleniumCheckSettings().match_level(MatchLevel.LAYOUT)
    assert res == check_settings_keyword.match_level("LAYOUT")
def test_variation_group_id(check_settings_keyword):
    res = SeleniumCheckSettings().variation_group_id("group id")
    assert res == check_settings_keyword.variation_group_id("group id")
def test_scroll_root_element_by_selector(check_settings_keyword, css_selector,
                                         by_selector):
    res = SeleniumCheckSettings().scroll_root_element(by_selector)
    assert res == check_settings_keyword.scroll_root_element_by_selector(
        css_selector)
def test_scroll_root_element_by_element(check_settings_keyword, web_element):
    res = SeleniumCheckSettings().scroll_root_element(web_element)
    assert res == check_settings_keyword.scroll_root_element_by_element(
        web_element)
def test_before_render_screenshot_hook():
    cs = SeleniumCheckSettings()
    cs.before_render_screenshot_hook("some hook")
    assert cs.values.script_hooks["beforeCaptureScreenshot"] == "some hook"
Example #20
0
def test_selenium_eyes_check_args_both_positional(eyes_check_mock):
    eyes_check_mock.check("A", SeleniumCheckSettings())

    assert eyes_check_mock.calls == [call(SeleniumCheckSettings().with_name("A"))]
def test_enable_patterns(check_settings_keyword):
    res = SeleniumCheckSettings().enable_patterns()
    assert res == check_settings_keyword.enable_patterns()
def test_before_render_screenshot_hook(check_settings_keyword):
    res = SeleniumCheckSettings().before_render_screenshot_hook(
        '{"script":34}')
    assert res == check_settings_keyword.before_render_screenshot_hook(
        '{"script":34}')
def test_default_check_settings():
    check_settings = SeleniumCheckSettings()

    assert check_settings.values.disable_browser_fetching is None
    assert check_settings.values.layout_breakpoints is None
    assert check_settings.values.lazy_load is None
def test_ignore_displacements(check_settings_keyword):
    res = SeleniumCheckSettings().ignore_displacements()
    assert res == check_settings_keyword.ignore_displacements()
Example #25
0
def test_selenium_eyes_check_args_only_settings_positional(eyes_check_mock):
    eyes_check_mock.check(SeleniumCheckSettings())

    assert eyes_check_mock.calls == [call(SeleniumCheckSettings())]
def test_ignore_caret(check_settings_keyword):
    res = SeleniumCheckSettings().ignore_caret()
    assert res == check_settings_keyword.ignore_caret()
Example #27
0
def test_selenium_eyes_check_args_both_keyword(eyes_check_mock):
    eyes_check_mock.check(check_settings=SeleniumCheckSettings(), name="A")

    assert eyes_check_mock.calls == [call(SeleniumCheckSettings().with_name("A"))]
def test_fully(check_settings_keyword):
    res = SeleniumCheckSettings().fully()
    assert res == check_settings_keyword.fully()
Example #29
0
def test_selenium_eyes_check_args_override_name(eyes_check_mock):
    eyes_check_mock.check("A", SeleniumCheckSettings().with_name("B"))

    assert eyes_check_mock.calls == [call(SeleniumCheckSettings().with_name("A"))]
def test_with_name(check_settings_keyword):
    res = SeleniumCheckSettings().with_name("NAME")
    assert res == check_settings_keyword.with_name("NAME")