Exemple #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)
Exemple #2
0
    def test_secret_masks_text(self):
        """the_secret sets text_to_log to [CENSORED]"""
        text = "Keep it a secret to everybody"
        e = Enter.the_secret(text)

        assert e.text == text
        assert e.text_to_log == "[CENSORED]"
Exemple #3
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)
Exemple #4
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),
        )
Exemple #5
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 #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))
Exemple #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
Exemple #8
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)
Exemple #9
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"))
Exemple #10
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
Exemple #11
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))