Example #1
0
    def test_exception_raised_if_element_not_found(self, mocker, region):
        mocker.patch("clickshot.element.Mouse")
        retry_with_timeout = mocker.patch("clickshot.element.retry_with_timeout")
        retry_with_timeout.side_effect = ElementNotFoundError()
        element = Element(ElementConfig(name="my_element"), region)
        element.save_last_screenshot = mocker.Mock()

        with pytest.raises(ElementNotFoundError):
            element.wait_until_visible()
Example #2
0
    def test_returns_false_if_element_not_found(self, mocker, region):
        mocker.patch("clickshot.element.Mouse")
        retry_with_timeout = mocker.patch("clickshot.element.retry_with_timeout")
        retry_with_timeout.side_effect = ElementNotFoundError()
        element = Element(ElementConfig(name="my_element"), region)

        result = element.is_visible()

        assert_that(result, is_(False))
Example #3
0
    def test_screenshot_saved_if_element_not_found(self, mocker, region):
        mocker.patch("clickshot.element.Mouse")
        retry_with_timeout = mocker.patch("clickshot.element.retry_with_timeout")
        retry_with_timeout.side_effect = ElementNotFoundError()

        element = Element(ElementConfig(name="my_element"), region)
        element.save_last_screenshot = mock.Mock()

        with pytest.raises(ElementNotFoundError):
            element.click()

        element.save_last_screenshot.assert_called()
Example #4
0
    def test_failsafe_aborts_is_visible_attempt(self, mocker, region):
        Mouse = mocker.patch("clickshot.element.Mouse")
        position_mock = mocker.PropertyMock(return_value=(0, 0))
        type(Mouse()).position = position_mock

        Locater = mocker.patch("clickshot.element.Locater")
        Locater().locate.side_effect = ElementNotFoundError()

        element = Element(ElementConfig(name="my_element"), region)

        with pytest.warns(UserWarning):
            result = element.is_visible(30)

        assert_that(result, is_(False))
Example #5
0
    def test_failsafe_aborts_click_attempt(self, mocker, region):
        Mouse = mocker.patch("clickshot.element.Mouse")
        position_mock = mocker.PropertyMock(return_value=(0, 0))
        type(Mouse()).position = position_mock

        Locater = mocker.patch("clickshot.element.Locater")
        Locater().locate.side_effect = ElementNotFoundError()

        element = Element(ElementConfig(name="my_element"), region)
        element.save_last_screenshot = mock.Mock()

        with pytest.raises(ElementNotFoundError):
            with pytest.warns(UserWarning):
                element.click()