Exemple #1
0
    def test_can_be_chained(self, MockedActionChains, Tester):
        """MoveMouse can be chained"""
        offset = (1, 2)

        Tester.attempts_to(Chain(MoveMouse.by_offset(*offset)))

        MockedActionChains().move_by_offset.assert_called_once_with(*offset)
Exemple #2
0
    def test_can_be_chained(self, MockedActionChains, Tester):
        """Pause when chained calls .pause()"""
        duration = 20

        Tester.attempts_to(Chain(Pause.for_(duration).seconds_because("... reasons")))

        MockedActionChains().pause.assert_called_once_with(duration)
Exemple #3
0
    def test_chained_calls_send_keys(self, MockedActionChains, Tester):
        """Enter chained with no element calls .send_keys()"""
        text = "test"

        Tester.attempts_to(Chain(Enter.the_text(text)))

        MockedActionChains().send_keys.assert_called_once_with(text)
Exemple #4
0
    def test_can_be_chained(self, MockedActionChains, Tester):
        """Click chained calls .click()"""
        mock_target = mock.Mock()
        mock_element = "element"
        mock_target.found_by.return_value = mock_element

        Tester.attempts_to(Chain(Click.on_the(mock_target)))

        MockedActionChains().click.assert_called_once_with(mock_element)
Exemple #5
0
    def test_calls_double_click(self, MockedActionChains, Tester):
        """RightClick calls .context_click()"""
        mock_target = mock.Mock()
        mock_element = "element"
        mock_target.found_by.return_value = mock_element

        Tester.attempts_to(Chain(RightClick.on_the(mock_target)))

        MockedActionChains().context_click.assert_called_once_with(
            on_element=mock_element
        )
Exemple #6
0
    def test_chained_calls_send_keys_to_element(self, MockedActionChains, Tester):
        """Enter chained with an element calls .send_keys_to_element()"""
        mock_target = mock.Mock()
        mock_element = "element"
        mock_target.found_by.return_value = mock_element
        text = "test"

        Tester.attempts_to(Chain(Enter.the_text(text).into_the(mock_target)))

        MockedActionChains().send_keys_to_element.assert_called_once_with(
            mock_element, text
        )
Exemple #7
0
    def test_can_be_chained(self, MockedActionChains, Tester):
        """Enter2FAToken when chained calls .send_keys_to_element()"""
        text = "test"
        mocked_2fa = Tester.ability_to(AuthenticateWith2FA)
        mocked_2fa.to_get_token.return_value = text
        mock_target = mock.Mock()
        mock_element = "element"
        mock_target.found_by.return_value = mock_element

        Tester.attempts_to(Chain(Enter2FAToken.into_the(mock_target)))

        MockedActionChains().send_keys_to_element.assert_called_once_with(
            mock_element, text
        )
Exemple #8
0
    def test_drag_and_drop(self):
        """
        User is able to drag and drop.

        Expected to fail because there is currently an issue in ActionChains.
        """
        Perry = self.actor

        given(Perry).was_able_to(Open.their_browser_on(URL))
        when(Perry).attempts_to(
            Wait.for_the(FIRST_DRAGGABLE_BOX).to_be_clickable(),
            Chain(
                HoldDown.left_mouse_button().on_the(FIRST_DRAGGABLE_BOX),
                MoveMouse.to_the(SECOND_DRAGGABLE_BOX),
                Release.left_mouse_button(),
            ),
        )
        then(Perry).should_see_the(
            (Text.of_the(FIRST_DRAGGABLE_BOX), ReadsExactly("B")))
Exemple #9
0
    def test_without_element(self, MockedActionChains, Tester):
        """RightClick works with no target"""
        Tester.attempts_to(Chain(RightClick()))

        MockedActionChains().context_click.assert_called_once_with(on_element=None)
Exemple #10
0
    def test_uses_click_and_hold(self, MockedActionChains, Tester):
        """Release left mouse button uses ActionChains.release"""
        Tester.attempts_to(Chain(Release.left_mouse_button()))

        MockedActionChains().release.assert_called_once()
Exemple #11
0
    def test_uses_key_down(self, MockedActionChains, Tester):
        """Release key uses ActionChains.key_up"""
        Tester.attempts_to(Chain(Release(Keys.ALT)))

        MockedActionChains().key_up.assert_called_once_with(Keys.ALT)
Exemple #12
0
    def test_uses_click_and_hold(self, MockedActionChains, Tester):
        """HoldDown left mouse button uses ActionChains.click_and_hold"""
        Tester.attempts_to(Chain(HoldDown.left_mouse_button()))

        MockedActionChains().click_and_hold.assert_called_once()
Exemple #13
0
    def test_uses_key_down(self, MockedActionChains, Tester):
        """HoldDown key uses ActionChains.key_down"""
        Tester.attempts_to(Chain(HoldDown(Keys.ALT)))

        MockedActionChains().key_down.assert_called_once_with(Keys.ALT)