def test_target_path_frame_by_css_selector():
    path = TargetPath.frame(By.CSS_SELECTOR, ".css")

    assert type(path) is FrameLocator
    assert path.by is By.CSS_SELECTOR
    assert path.selector == ".css"
    assert path.number_or_id_or_name is None
    assert path.parent is None
def test_target_region_within_frame():
    path = TargetPath.frame(1).region(".css")

    assert type(path) is RegionLocator
    assert path.by is By.CSS_SELECTOR
    assert path.selector == ".css"
    assert type(path.parent) is FrameLocator
    assert path.parent.number_or_id_or_name == 1
def test_target_path_frame_by_number():
    path = TargetPath.frame(1)

    assert type(path) is FrameLocator
    assert path.by is None
    assert path.selector is None
    assert path.number_or_id_or_name == 1
    assert path.parent is None
def test_target_path_frame_region_eq():
    assert TargetPath.frame(1).region(".css") == TargetPath.frame(1).region(
        ".css")
    assert TargetPath.frame(1).region(".css") != TargetPath.frame(1).region(
        "#id")
    assert TargetPath.frame(1).region(".css") != TargetPath.frame(2).region(
        ".css")
def test_check_frame(method_name="frame"):
    frame_reference = "frame-name-or-id"
    cs = get_cs_from_method(method_name, frame_reference)
    assert cs.values.frame_chain[0].frame_name_or_id == frame_reference

    frame_selector = [By.ID, "some-selector"]
    cs = get_cs_from_method(method_name, frame_selector)
    assert cs.values.frame_chain[0].frame_selector == TargetPath.frame(
        By.ID, "some-selector")

    frame_index = 3
    cs = get_cs_from_method(method_name, frame_index)
    assert cs.values.frame_chain[0].frame_index == frame_index
Пример #6
0
def test_transformed_selector_convert_frame_by_css_region_by_css():
    converted = TransformedSelector.convert(
        True,
        TargetPath.frame(By.CSS_SELECTOR, "#s").region(".css"))

    assert converted.type is By.CSS_SELECTOR
    assert converted.selector == "#s"
    assert converted.shadow is None
    assert type(converted.frame) is TransformedSelector
    assert converted.frame.type is By.CSS_SELECTOR
    assert converted.frame.selector == ".css"
    assert converted.frame.shadow is None
    assert converted.frame.frame is None
def test_target_path_frame_shadow_region_repr():
    path = TargetPath.frame(1).shadow("#shadow").region(".region")

    assert repr(
        path) == "TargetPath.frame(1).shadow('#shadow').region('.region')"
def test_target_path_frame_css_repr():
    path = TargetPath.frame(By.CSS_SELECTOR, ".css")

    assert repr(path) == "TargetPath.frame(By.CSS_SELECTOR, '.css')"
def test_target_path_frame_name_repr():
    path = TargetPath.frame("frame")

    assert repr(path) == "TargetPath.frame('frame')"
Пример #10
0
def test_target_path_frame_number_repr():
    path = TargetPath.frame(1)

    assert repr(path) == "TargetPath.frame(1)"
        ),
        TestData(
            "check_frame_by_index",
            check_region=1,
            check_region_result=FrameLocator(frame_index=1),
        ),
        TestData(
            "check_frame_by_name",
            check_region="framename",
            check_region_result=FrameLocator(frame_name_or_id="framename"),
        ),
        TestData(
            "check_frame_by_selector",
            check_region="id:overflow-div",
            check_region_result=FrameLocator(
                frame_selector=TargetPath.frame(By.ID, "overflow-div")),
        ),
    ],
    ids=lambda d: str(d),
)
def test_check_frame(check_keyword, data):
    call_method = getattr(check_keyword, data.method)

    with mock.patch("robot.libraries.BuiltIn.BuiltIn.run_keyword",
                    side_effect=run_keyword):
        call_method(*data.check_params)

    check_settings, tag = check_keyword.results[0]
    assert tag == data.check_tag
    assert check_settings.values.frame_chain == [data.check_region_result]
    assert check_settings.values.ignore_regions == data.check_settings_data.result