コード例 #1
0
ファイル: test_dropdowns.py プロジェクト: Z-Brueske/screenpy
    def test_select_by_index(self):
        """Can select an option from a dropdown by index."""
        Perry = self.actor

        given(Perry).was_able_to(Open.their_browser_on(URL))
        when(Perry).attempts_to(
            Select.the_option_at_index(1).from_(THE_DROPDOWN))
        then(Perry).should_see_the(
            (Selected.option_from(THE_DROPDOWN), ReadsExactly("Option 1")))
コード例 #2
0
    def test_select_by_index(self):
        Perry = self.actor

        given(Perry).was_able_to(Start.on_the_homepage())
        when(Perry).attempts_to(
            Click.on_the(DROPDOWN_LINK).then_wait_for(THE_DROPDOWN))
        and_(Perry).attempts_to(
            Select.the_option_at_index(1).from_(THE_DROPDOWN))
        then(Perry).should_see_the(
            (Selected.option_from(THE_DROPDOWN), ReadsExactly("Option 1")))
コード例 #3
0
    def test_specifics_can_be_instantiated(self):
        """Select's specific classes can be instantiated"""
        by_index1 = Select.the_option_at_index(0)
        by_index2 = Select.the_option_at_index(0).from_(None)
        by_index3 = Select.the_option_at_index(0).from_the(None)
        by_text1 = Select.the_option_named("Option")
        by_text2 = Select.the_option_named("Option").from_(None)
        by_text3 = Select.the_option_named("Option").from_the(None)
        by_value1 = Select.the_option_with_value(1)
        by_value2 = Select.the_option_with_value(1).from_(None)
        by_value3 = Select.the_option_with_value(1).from_the(None)

        assert isinstance(by_index1, SelectByIndex)
        assert isinstance(by_index2, SelectByIndex)
        assert isinstance(by_index3, SelectByIndex)
        assert isinstance(by_text1, SelectByText)
        assert isinstance(by_text2, SelectByText)
        assert isinstance(by_text3, SelectByText)
        assert isinstance(by_value1, SelectByValue)
        assert isinstance(by_value2, SelectByValue)
        assert isinstance(by_value3, SelectByValue)
コード例 #4
0
    def test_basic_action(self, mocked_selenium_select, Tester):
        """SelectByIndex finds its target and calls .select_by_index()"""
        index = 1
        fake_xpath = "//xpath"
        fake_target = Target.the("fake").located_by(fake_xpath)

        Tester.attempts_to(
            Select.the_option_at_index(index).from_the(fake_target))

        mocked_btw = Tester.ability_to(BrowseTheWeb)
        mocked_btw.to_find.assert_called_once_with(fake_target)
        mocked_selenium_select.return_value.select_by_index.assert_called_once_with(
            str(index))
コード例 #5
0
 def test_complains_for_no_target(self, Tester):
     """SelectByIndex complains if no target was given"""
     with pytest.raises(UnableToActError):
         Tester.attempts_to(Select.the_option_at_index(1))