コード例 #1
0
    def test_can_be_instantiated(self):
        """Text can be instantiated"""
        t1 = Text.of(None)
        t2 = Text.of_all(None)

        assert isinstance(t1, Text)
        assert isinstance(t2, Text)
コード例 #2
0
    def answered_by(self, the_actor: Actor) -> str:
        """
        Direct the actor to read off the text of the results message.

        Args:
            the_actor:
        """
        return Text.of(RESULTS_MESSAGE).answered_by(the_actor)
コード例 #3
0
ファイル: test_frames.py プロジェクト: Z-Brueske/screenpy
    def test_switch_to_iframe(self):
        """User is able to switch to an iframe."""
        Perry = self.actor

        given(Perry).was_able_to(Open.their_browser_on(URL))
        when(Perry).attempts_to(SwitchTo.the(WYSIWYG_IFRAME))
        then(Perry).should_see_the(
            (Text.of_the(CONTENT_BOX), ReadsExactly("Your content goes here."))
        )
コード例 #4
0
    def test_dismiss_alert(self):
        """User can dismiss an alert."""
        Perry = self.actor

        given(Perry).was_able_to(
            Open.their_browser_on(URL), Click.on_the(JS_CONFIRM_BUTTON)
        )
        when(Perry).attempts_to(DismissAlert())
        then(Perry).should_see_the(
            (Text.of_the(RESULT_MESSAGE), ReadsExactly("You clicked: Cancel"))
        )
コード例 #5
0
    def test_respond_to_prompt(self):
        """User can enter text into a prompt."""
        Perry = self.actor
        test_text = "Hello! I am responding to this prompt."

        given(Perry).was_able_to(
            Open.their_browser_on(URL), Click.on_the(JS_PROMPT_BUTTON)
        )
        when(Perry).attempts_to(RespondToPrompt.with_(test_text))
        then(Perry).should_see_the(
            (Text.of_the(RESULT_MESSAGE), ReadsExactly(f"You entered: {test_text}"))
        )
コード例 #6
0
def test_contains_the_text_no_it_doesnt(Tester):
    """ContainsTheText complains if the substring does not exist"""
    fake_xpath = "//xpath"
    fake_target = Target.the("fake").located_by(fake_xpath)
    mocked_btw = Tester.ability_to(BrowseTheWeb)
    mocked_element = mock.Mock()
    mocked_element.text = "spam and eggs"
    mocked_btw.to_find.return_value = mocked_element

    with pytest.raises(AssertionError):
        Tester.should_see_the(
            (Text.of_the(fake_target), ContainsTheText("baked beans")))
コード例 #7
0
def test_ask_for_text(Tester):
    """Text finds its target and gets its text"""
    text = "spam"
    fake_xpath = "//xpath"
    fake_target = Target.the("fake").located_by(fake_xpath)
    mocked_btw = Tester.ability_to(BrowseTheWeb)
    mocked_element = mock.Mock()
    mocked_element.text = f"{text} and eggs"
    mocked_btw.to_find.return_value = mocked_element

    Tester.should_see_the((Text.of_the(fake_target), ContainsTheText(text)))

    mocked_btw.to_find.assert_called_once_with(fake_target)
コード例 #8
0
    def test_switch_to_iframe(self):
        """User is able to switch to an iframe."""
        Perry = self.actor

        given(Perry).was_able_to(Open.their_browser_on(URL))
        when(Perry).attempts_to(
            Click.on_the(CLICK_HERE_LINK),
            Pause.for_(1).second_because("Selenium needs to catch up"),
            SwitchToTab.on_top(),
        )
        then(Perry).should_see_the(
            (BrowserURL(), ContainsTheText("windows/new")),
            (Text.of_the(HEADER_MESSAGE), ReadsExactly("New Window")),
        )
コード例 #9
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")))
コード例 #10
0
    def test_of_all_sets_multi(self):
        """Text.of_all sets multi to True"""
        multi_text = Text.of_all(None)

        assert multi_text.multi
コード例 #11
0
 def answered_by(self, the_actor):
     return Text.of_all(SEARCH_RESULTS).answered_by(the_actor)
コード例 #12
0
 def answered_by(self, the_actor):
     return Text.of(home_page.WELCOME_MESSAGE).answered_by(the_actor)
コード例 #13
0
 def answered_by(self, the_actor):
     return Text.of(RESULTS_MESSAGE).answered_by(the_actor)