示例#1
0
    def test_add_one_element(self):
        """User is able to add one element."""
        Perry = self.actor

        given(Perry).was_able_to(Open.their_browser_on(URL))
        when(Perry).attempts_to(Click.on_the(ADD_BUTTON),
                                Wait.for_the(ADDED_ELEMENTS))
        then(Perry).should_see_the((Element(ADDED_ELEMENTS), IsVisible()))
    def test_add_one_element(self):
        Perry = self.actor

        given(Perry).was_able_to(Start.on_the_homepage())
        when(Perry).attempts_to(
            Click.on_the(ADD_REMOVE_ELEMENTS_LINK),
            Wait.for_the(ADD_BUTTON).to_appear()
        )
        and_(Perry).attempts_to(Click.on_the(ADD_BUTTON).then_wait_for(ADDED_ELEMENTS))
        then(Perry).should_see_the((Number.of(ADDED_ELEMENTS), IsEqualTo(1)))
示例#3
0
def test_wait(Tester):
    """Wait calls .to_wait_for()"""
    fake_xpath = "//xpath"
    fake_target = Target.the("fake").located_by(fake_xpath)

    Tester.attempts_to(Wait.for_the(fake_target).to_appear())

    mocked_btw = Tester.ability_to(BrowseTheWeb)
    mocked_btw.to_wait_for.assert_called_once_with(
        fake_target, timeout=20, cond=EC.visibility_of_element_located)
示例#4
0
    def test_remove_element(self):
        """User is able to remove an element that was added."""
        Perry = self.actor

        given(Perry).was_able_to(
            Open.their_browser_on(URL),
            Click.on_the(ADD_BUTTON),
            Wait.for_the(ADDED_ELEMENTS),
        )
        when(Perry).attempts_to(Click.on_the(ADDED_ELEMENTS))
        then(Perry).should_see_the((Number.of(ADDED_ELEMENTS), IsEqualTo(0)))
示例#5
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),
        )
    def test_add_many_elements(self):
        Perry = self.actor
        repeat = random.choice(range(2, 10))

        given(Perry).was_able_to(Start.on_the_homepage())
        when(Perry).attempts_to(
            Click.on_the(ADD_REMOVE_ELEMENTS_LINK),
            Wait.for_the(ADD_BUTTON).to_appear()
        )
        and_(Perry).attempts_to(
            *(
                Click.on_the(ADD_BUTTON).then_wait_for(ADDED_ELEMENTS)
                for each_time in range(repeat)
            )
        )
        then(Perry).should_see_the((Number.of(ADDED_ELEMENTS), IsEqualTo(repeat)))
示例#7
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")))