def test_add_collaborator(web_fixture, access_domain_fixture, access_ui_fixture): """A user may add other users as collaborators to his address book, specifying the privileges in the process.""" browser = access_ui_fixture.browser address_book = access_domain_fixture.address_book account = access_domain_fixture.account other_address_book = access_domain_fixture.other_address_book other_account = access_domain_fixture.other_account web_fixture.log_in(browser=browser, system_account=account) browser.open('/') assert address_book not in AddressBook.address_books_visible_to( other_account) assert not address_book.can_be_edited_by(other_account) assert not address_book.can_be_added_to_by(other_account) browser.click(XPath.link().with_text('Address book of [email protected]')) browser.click(XPath.link().with_text('Add collaborator')) browser.select(XPath.select_labelled('Choose collaborator'), '*****@*****.**') browser.click(XPath.input_labelled('May add new addresses')) browser.click(XPath.input_labelled('May edit existing addresses')) browser.click(XPath.button_labelled('Share')) assert access_ui_fixture.is_on_address_book_page_of('*****@*****.**') assert address_book in AddressBook.address_books_visible_to(other_account) assert address_book.can_be_edited_by(other_account) assert address_book.can_be_added_to_by(other_account)
def test_browser_back_after_state_changes_goes_to_previous_url(web_fixture, query_string_fixture, responsive_disclosure_fixture): """If a browser stores an URL in its history, which is the same as the one a user is currently on, when you navigate history to get back to that URL, the page is rendered with newer state.""" fixture = responsive_disclosure_fixture wsgi_app = web_fixture.new_wsgi_app(enable_js=True, child_factory=fixture.MainWidget.factory()) web_fixture.reahl_server.set_app(wsgi_app) browser = web_fixture.driver_browser class FormWithButton(fixture.MyForm): def __init__(self, view, an_object): super(FormWithButton, self).__init__(view, an_object) self.define_event_handler(self.events.submit) self.add_child(ButtonInput(self, self.events.submit)) @exposed def events(self, events): events.submit = Event(label='Submit') fixture.MyForm = FormWithButton # create some state on the server side for this URL browser.open('/') assert browser.wait_for(query_string_fixture.is_state_now, 1) browser.select(XPath.select_labelled('Choice'), 'Two') assert browser.wait_for(query_string_fixture.is_state_now, 2) # submit the page, so we get redirected to the same URL, leaving itself in browser history (webkit only) browser.click(XPath.button_labelled('Submit')) assert browser.current_url.path == '/' # create different state on the same URL we were redirected to browser.select(XPath.select_labelled('Choice'), 'Three') # when the user navigates back to the same url in history, the page retains the youngest state browser.go_back() browser.wait_for_page_to_load() # to prevent it from flipping - we know it is reloaded in js assert browser.current_url.path == '/' assert browser.wait_for(query_string_fixture.is_state_now, 3)
def change_value(browser): browser.select(XPath.select_labelled('Choice'), 'Three')