def test_element_handles_index_error():
    driver = MockDriver()
    find = Finder(driver, None)

    element = find.element(PageElement(By.CLASS_NAME, ""))

    assert_that(element, equal_to(None),
                "None should be returned when no elements can be found")
def test_element():
    driver = MockDriver()
    find = Finder(driver, None)

    element = find.element(PageElement(By.CLASS_NAME, "test-class"))

    assert_that(
        element.info,
        equal_to("elements found by 'class name' using value 'test-class'"),
        "An element should be found")
Example #3
0
def test_switch_to_frame():
    mock_driver = MagicMock(name="driver")
    finder = Finder(mock_driver, MagicMock(name="logger"))
    interrogator = Interrogator(mock_driver, finder, "logger")
    waiter = Waiter(mock_driver, finder, "logger")
    test_interactor = Interactor(mock_driver, finder, interrogator, waiter,
                                 "logger")
    frame_to_find = PageElement(By.ID, "frame_id")

    test_interactor.switch_to_frame(frame_to_find)

    mock_driver.switch_to.frame.assert_called_once_with(
        finder.element(frame_to_find))