def test_can_be_instantiated(self): """Selected can be instantiated""" s1 = Selected.option_from(None) s2 = Selected.option_from_the(None) s3 = Selected.options_from(None) s4 = Selected.options_from_the(None) assert isinstance(s1, Selected) assert isinstance(s2, Selected) assert isinstance(s3, Selected) assert isinstance(s4, Selected)
def test_select_by_value(self): """Can select an option from a dropdown by value.""" Perry = self.actor given(Perry).was_able_to(Open.their_browser_on(URL)) when(Perry).attempts_to( Select.the_option_with_value(2).from_(THE_DROPDOWN)) then(Perry).should_see_the( (Selected.option_from(THE_DROPDOWN), ReadsExactly("Option 2")))
def test_reads_exactly_mismatched_string(mocked_selenium_select, Tester): """ReadsExactly complains if the strings do not match exactly""" fake_xpath = "//xpath" fake_target = Target.the("fake").located_by(fake_xpath) mocked_selenium_select.return_value.first_selected_option.text = "sentences" with pytest.raises(AssertionError): Tester.should_see_the( (Selected.option_from(fake_target), ReadsExactly("sandwiches")))
def test_select_by_value(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_with_value(2).from_(THE_DROPDOWN)) then(Perry).should_see_the( (Selected.option_from(THE_DROPDOWN), ReadsExactly("Option 2")))
def test_ask_for_selected(mocked_selenium_select, Tester): """Selected finds its target and gets the first_selected_option""" fake_xpath = "//xpath" fake_target = Target.the("fake").located_by(fake_xpath) return_value = "test" mocked_selenium_select.return_value.first_selected_option.text = return_value Tester.should_see_the( (Selected.option_from(fake_target), ReadsExactly(return_value))) mocked_btw = Tester.ability_to(BrowseTheWeb) mocked_btw.to_find.assert_called_once_with(fake_target)
def test_options_from_sets_multi(self): """Selected.options_from sets multi to True""" multi_selected = Selected.options_from(None) assert multi_selected.multi