Beispiel #1
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)
Beispiel #2
0
    def test_basic_action(self, Tester):
        """Enter finds its target and calls .send_keys()"""
        text = "test"
        fake_xpath = "//xpath"
        fake_target = Target.the("fake").located_by(fake_xpath)

        Tester.attempts_to(Enter.the_text(text).into_the(fake_target))

        mocked_btw = Tester.ability_to(BrowseTheWeb)
        mocked_btw.to_find.assert_called_once_with(fake_target)
        mocked_btw.to_find.return_value.send_keys.assert_called_once_with(text)
Beispiel #3
0
    def perform_as(self, the_actor: Actor) -> None:
        """
        Direct the actor to search github for the given term.

        Args:
            the_actor: the actor who will perform this task.
        """
        the_actor.attempts_to(
            Enter.the_text(self.search_query).into(SEARCH_INPUT).then_hit(
                Keys.RETURN),
            Wait.for_the(RESULTS_MESSAGE),
        )
Beispiel #4
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
        )
Beispiel #5
0
    def test_can_be_instantiated(self):
        """Enter can be instantiated"""
        e1 = Enter.the_text("test")
        e2 = Enter.the_text("test").into(None)
        e3 = Enter.the_keys("test").into(None)
        e4 = Enter.the_text("test").into_the(None)
        e5 = Enter.the_text("test").on(None)
        e6 = Enter.the_keys("test").on(None)
        e7 = Enter.the_text("test").into(None).then_press(None)
        e9 = Enter.the_secret("test")
        e8 = Press.the_keys("test")

        assert isinstance(e1, Enter)
        assert isinstance(e2, Enter)
        assert isinstance(e3, Enter)
        assert isinstance(e4, Enter)
        assert isinstance(e5, Enter)
        assert isinstance(e6, Enter)
        assert isinstance(e7, Enter)
        assert isinstance(e8, Enter)
        assert isinstance(e9, Enter)
Beispiel #6
0
    def perform_as(self, the_actor: Actor) -> None:
        """
        Asks the actor to perform the Enter2FAToken action, which will get the
        current token using the actor's AuthenticateWith2FA ability.

        Args:
            the_actor: the |Actor| who will perform this action.

        Raises:
            |UnableToPerformError|: if the actor does not have the
                abilities to |AuthenticateWith2FA| and |BrowseTheWeb|.
        """
        token = the_actor.uses_ability_to(AuthenticateWith2FA).to_get_token()
        the_actor.attempts_to(Enter.the_text(token).into_the(self.target))
Beispiel #7
0
    def test_following_keys(self, Tester):
        """Enter hits the following keys"""
        text = "test"
        fake_xpath = "//xpath"
        fake_target = Target.the("fake").located_by(fake_xpath)

        Tester.attempts_to(
            Enter.the_text(text).into_the(fake_target).then_hit(Keys.ENTER))

        mocked_btw = Tester.ability_to(BrowseTheWeb)
        mocked_btw.to_find.assert_called_once_with(fake_target)
        mocked_element = mocked_btw.to_find.return_value
        assert mocked_element.send_keys.call_count == 2
        called_args, _ = mocked_element.send_keys.call_args_list[1]
        assert Keys.ENTER in called_args
Beispiel #8
0
 def test_complains_for_no_target(self, Tester):
     """Enter complains if no target was given"""
     with pytest.raises(UnableToActError):
         Tester.attempts_to(Enter.the_text("test"))
Beispiel #9
0
    def test_text_to_log_humanizes_keys(self):
        """unicode key values are turned into human-readable text"""
        e = Enter.the_text(Keys.ENTER)

        assert "ENTER" in e.text_to_log
Beispiel #10
0
 def perform_as(self, the_actor):
     the_actor.attempts_to(
         Enter.the_text(self.search_query).into(SEARCH_INPUT).then_hit(
             Keys.RETURN).then_wait_for(RESULTS_MESSAGE))