예제 #1
0
def add_collaborator(fixture):
    """A user may add other users as collaborators to his address book, specifying the privileges in the process."""
    browser = fixture.browser
    account = fixture.account
    address_book = fixture.address_book

    other_address_book = fixture.other_address_book
    other_account = fixture.other_account

    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 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)
예제 #2
0
    def detour_is_non_reentrant(self, fixture):
        """Once detoured to a View marked as the start of a Detour, a Bookmark to that View itself
        will not re-enter the detour.
        """
        class MainUI(UserInterface):
            def assemble(self):
                self.define_page(HTML5Page).use_layout(
                    PageLayout(
                        contents_layout=ColumnLayout('main').with_slots()))

                step1 = self.define_view('/firstStepOfDetour',
                                         title='Step 1',
                                         detour=True)
                step1.set_slot(
                    'main', A.factory_from_bookmark(step1.as_bookmark(self)))

                home = self.define_view('/initial', title='View a')
                home.set_slot('main',
                              A.factory_from_bookmark(step1.as_bookmark(self)))

        wsgi_app = fixture.new_wsgi_app(site_root=MainUI)
        browser = Browser(wsgi_app)

        def locationIsSetToReturnTo(url_path):
            return urllib_parse.parse_qs(
                browser.location_query_string)['returnTo'] == [url_path]

        browser.open('/initial')
        browser.click(XPath.link_with_text('Step 1'))
        vassert(browser.location_path == '/firstStepOfDetour')
        vassert(locationIsSetToReturnTo('http://localhost/initial'))

        browser.click(XPath.link_with_text('Step 1'))
        vassert(browser.location_path == '/firstStepOfDetour')
        vassert(locationIsSetToReturnTo('http://localhost/initial'))
예제 #3
0
def clicking_on_different_tabs_switch(fixture):
    """Clicking on tabs change the contents that are displayed as well as the active tab."""
    fixture.reahl_server.set_app(fixture.wsgi_app)
    fixture.driver_browser.open('/')

    # Clicking on 3 (a normal tab), changes the current tab
    vassert(
        fixture.driver_browser.wait_for_not(fixture.tab_is_active,
                                            'tab 3 name'))
    vassert(
        fixture.driver_browser.wait_for_not(fixture.tab_contents_equals,
                                            '<p>tab 3 content</p>'))

    fixture.driver_browser.click(XPath.link_with_text('tab 3 name'))

    vassert(
        fixture.driver_browser.wait_for(fixture.tab_is_active, 'tab 3 name'))
    vassert(
        fixture.driver_browser.wait_for(fixture.tab_contents_equals,
                                        '<p>tab 3 content</p>'))

    fixture.driver_browser.click(XPath.link_with_text('tab 4 name'))

    vassert(
        fixture.driver_browser.wait_for_not(fixture.tab_is_active,
                                            'tab 3 name'))
    vassert(
        fixture.driver_browser.wait_for(fixture.tab_is_active, 'tab 4 name'))
    vassert(
        fixture.driver_browser.wait_for(fixture.tab_contents_equals,
                                        '<p>tab 4 content</p>'))
예제 #4
0
파일: test_nav.py 프로젝트: diopib/reahl
def language_menu(fixture):
    """A Nav can also be constructed to let a user choose to view the same page in 
       another of the supported languages."""
    class PanelWithMenu(Div):
        def __init__(self, view):
            super(PanelWithMenu, self).__init__(view)
            self.add_child(Menu(view).with_languages())
            self.add_child(P(view, text=_('This is an English sentence.')))

    wsgi_app = fixture.new_wsgi_app(child_factory=PanelWithMenu.factory())

    browser = Browser(wsgi_app)
    browser.open('/')

    vassert(
        browser.is_element_present(
            XPath.paragraph_containing('This is an English sentence.')))

    browser.click(XPath.link_with_text('Afrikaans'))
    vassert(
        browser.is_element_present(
            XPath.paragraph_containing('Hierdie is \'n sin in Afrikaans.')))

    browser.click(XPath.link_with_text('English (United Kingdom)'))
    vassert(
        browser.is_element_present(
            XPath.paragraph_containing('This is an English sentence.')))
예제 #5
0
def edit_and_add_own(fixture):
    """The owner of an AddressBook can add and edit Addresses to the owned AddressBook."""
    browser = fixture.browser
    account = fixture.account
    address_book = fixture.address_book

    fixture.log_in(browser=browser, system_account=account)
    browser.open('/')

    browser.click(XPath.link_with_text('Address book of [email protected]'))

    # add
    browser.click(XPath.link_with_text('Add address'))
    browser.type(XPath.input_labelled('Name'), 'Someone')
    browser.type(XPath.input_labelled('Email'), '*****@*****.**')
    browser.click(XPath.button_labelled('Save'))

    assert browser.is_element_present(
        XPath.paragraph_containing('Someone: [email protected]'))

    # edit
    browser.click(XPath.button_labelled('Edit'))
    browser.type(XPath.input_labelled('Name'), 'Else')
    browser.type(XPath.input_labelled('Email'), '*****@*****.**')
    browser.click(XPath.button_labelled('Update'))

    assert browser.is_element_present(
        XPath.paragraph_containing('Else: [email protected]'))
예제 #6
0
    def active_state_of_next_prev_links(self, fixture):
        """Next and Last links are only active when not on the last range of pages,
           and Prev and First are similarly deactive when on the first range of pages."""
        fixture.number_of_pages = 15
        fixture.max_page_links = 5
        fixture.reahl_server.set_app(fixture.wsgi_app)
        fixture.driver_browser.open('/')

        # Case: when you are on the left of the page range        
        vassert( not fixture.driver_browser.is_active(XPath.link_starting_with_text('←')) )
        vassert( not fixture.driver_browser.is_active(XPath.link_starting_with_text('«')) )
        vassert( fixture.driver_browser.is_active(XPath.link_starting_with_text('»')) )
        vassert( fixture.driver_browser.is_active(XPath.link_starting_with_text('→')) )

        # Case: when you are in the middle of the page range        
        fixture.driver_browser.click(XPath.link_starting_with_text('»'))
        fixture.driver_browser.wait_for_element_present(XPath.link_with_text('p6'))
        vassert( fixture.driver_browser.is_active(XPath.link_starting_with_text('←')) )
        vassert( fixture.driver_browser.is_active(XPath.link_starting_with_text('«')) )
        vassert( fixture.driver_browser.is_active(XPath.link_starting_with_text('»')) )
        vassert( fixture.driver_browser.is_active(XPath.link_starting_with_text('→')) )
        
        # Case: when you are at the end of the page range        
        fixture.driver_browser.click(XPath.link_starting_with_text('»'))
        fixture.driver_browser.wait_for_element_present(XPath.link_with_text('p11'))
        vassert( fixture.driver_browser.is_active(XPath.link_starting_with_text('←')) )
        vassert( fixture.driver_browser.is_active(XPath.link_starting_with_text('«')) )
        vassert( not fixture.driver_browser.is_active(XPath.link_starting_with_text('»')) )
        vassert( not fixture.driver_browser.is_active(XPath.link_starting_with_text('→')) )
예제 #7
0
def clicking_on_sub_tab_switches(fixture):
    """Clicking on a sub tab also changes the contents that are displayed as well as the active tab."""
    if not fixture.enable_js:
        fixture.ensure_disabled_js_files_not_cached()

    fixture.reahl_server.set_app(fixture.wsgi_app)
    fixture.driver_browser.open('/')

    fixture.driver_browser.click(XPath.link_with_text('tab 3 name'))
    vassert(
        fixture.driver_browser.wait_for(fixture.tab_is_active, 'tab 3 name'))
    vassert(
        fixture.driver_browser.wait_for(fixture.tab_contents_equals,
                                        '<p>tab 3 content</p>'))

    vassert(
        fixture.driver_browser.wait_for_not(fixture.tab_is_active,
                                            'tab 2 name'))
    vassert(
        fixture.driver_browser.wait_for_not(fixture.tab_contents_equals,
                                            '<p>tab 1/2 content</p>'))

    fixture.driver_browser.click(XPath.link_with_text('multitab name'))
    fixture.driver_browser.click(XPath.link_with_text('tab 2 name'))

    # - active status removed from previous
    vassert(
        fixture.driver_browser.wait_for_not(fixture.tab_is_active,
                                            'tab 3 name'))

    # - new status and contents set
    vassert(
        fixture.driver_browser.wait_for(fixture.tab_is_active, 'tab 2 name'))
    vassert(
        fixture.driver_browser.wait_for(fixture.tab_contents_equals,
                                        '<p>tab 1/2 content</p>'))

    # Clicking away from the multitab sub-tab removes its active status
    fixture.driver_browser.click(XPath.link_with_text('tab 3 name'))
    # tab2 is not active anymore
    if fixture.enable_js:
        pass
        ### assert None, 'This is a bug in bootstrap v4.0 alpha javascript'
    else:
        vassert(
            fixture.driver_browser.wait_for_not(fixture.tab_is_active,
                                                'tab 2 name'))
예제 #8
0
    def selecting_a_page(self, fixture):
        """Clicking the link of a page results in the contents of the PageContainer being refreshed."""
        fixture.reahl_server.set_app(fixture.wsgi_app)
        fixture.driver_browser.open('/')

        fixture.driver_browser.wait_for(fixture.container_contents_is, 'contents of page 1')
        fixture.driver_browser.click(XPath.link_with_text('p2'))
        fixture.driver_browser.wait_for(fixture.container_contents_is, 'contents of page 2')
예제 #9
0
파일: test_form.py 프로젝트: diopib/reahl
def button_layouts_on_anchors(fixture):
    """A ButtonLayout can also be used to make an A (anchor) look like a button."""

    anchor = A(fixture.view, href=Url('/an/href'),
               description='link text').use_layout(ButtonLayout())
    tester = WidgetTester(anchor)
    [rendered_anchor] = tester.xpath(XPath.link_with_text('link text'))
    vassert(rendered_anchor.attrib['class'] == 'btn')
예제 #10
0
def logging_in(fixture):
    """A user can log in by going to the Log in page.
       The name of the currently logged in user is displayed on the home page."""

    browser = fixture.browser
    account = fixture.account

    browser.open('/')
    browser.click(XPath.link_with_text('Log in'))

    browser.type(XPath.input_labelled('Email'), '*****@*****.**')
    browser.type(XPath.input_labelled('Password'), 'topsecret')
    browser.click(XPath.button_labelled('Log in'))

    browser.click(XPath.link_with_text('Home'))
    assert browser.is_element_present(
        XPath.paragraph_containing('Welcome [email protected]'))
예제 #11
0
def see_other(fixture):
    """If allowed, an account may see another account's AddressBook, and could edit or add Addresses, 
       depending on the allowed rights."""
    browser = fixture.browser
    account = fixture.account
    address_book = fixture.address_book

    other_address_book = fixture.other_address_book
    other_address_book.allow(account)
    Address(address_book=other_address_book,
            email_address='*****@*****.**',
            name='Friend').save()

    fixture.log_in(browser=browser, system_account=account)
    browser.open('/')

    browser.click(XPath.link_with_text('Address book of [email protected]'))

    assert browser.is_element_present(
        XPath.paragraph_containing('Friend: [email protected]'))

    # Case: can only see
    assert not browser.is_element_enabled(XPath.link_with_text('Add address'))
    assert not browser.is_element_enabled(XPath.button_labelled('Edit'))

    # Case: can edit only
    other_address_book.allow(account,
                             can_edit_addresses=True,
                             can_add_addresses=False)
    browser.refresh()
    assert not browser.is_element_enabled(XPath.link_with_text('Add address'))
    assert browser.is_element_enabled(XPath.button_labelled('Edit'))

    # Case: can add, and therefor also edit
    other_address_book.allow(account, can_add_addresses=True)
    browser.refresh()
    assert browser.is_element_enabled(XPath.link_with_text('Add address'))
    assert browser.is_element_enabled(XPath.button_labelled('Edit'))

    browser.click(XPath.button_labelled('Edit'))
    browser.type(XPath.input_labelled('Name'), 'Else')
    browser.type(XPath.input_labelled('Email'), '*****@*****.**')
    browser.click(XPath.button_labelled('Update'))

    assert browser.is_element_present(
        XPath.paragraph_containing('Else: [email protected]'))
예제 #12
0
def logging_in(fixture):
    """A user first sees only a login screen on the home page; after logging in, 
       all the address books visible to the user appear."""
    browser = fixture.browser
    account = fixture.account
    address_book = fixture.address_book

    other_address_book = fixture.other_address_book
    other_address_book.allow(account)

    browser.open('/')
    browser.type(XPath.input_labelled('Email'), '*****@*****.**')
    browser.type(XPath.input_labelled('Password'), fixture.password)
    browser.click(XPath.button_labelled('Log in'))

    assert browser.is_element_present(
        XPath.link_with_text('Address book of [email protected]'))
    assert browser.is_element_present(
        XPath.link_with_text('Address book of [email protected]'))
예제 #13
0
def widgets(fixture):
    fixture.start_example_app()
    fixture.driver_browser.open('/')
    vassert(
        fixture.driver_browser.wait_for(fixture.carousel_caption_equals,
                                        'a paragraph with text'))
    fixture.driver_browser.click(XPath.link_with_text('Next'))
    vassert(
        fixture.driver_browser.wait_for(fixture.carousel_caption_equals,
                                        'a different paragraph'))
예제 #14
0
def test_pageflow1(fixture):
    browser = Browser(fixture.wsgi_app)
    browser.open('/')

    vassert(browser.is_element_present('//ul[contains(@class,"nav")]'))

    browser.click(XPath.link_with_text('Add an address'))
    vassert(browser.location_path == '/add')

    browser.type(XPath.input_labelled('Name'), 'John')
    browser.type(XPath.input_labelled('Email'), '*****@*****.**')
    browser.click(XPath.button_labelled('Save'))

    vassert(browser.location_path == '/add')

    browser.click(XPath.link_with_text('Addresses'))
    vassert(browser.location_path == '/')
    vassert(
        browser.is_element_present(
            XPath.paragraph_containing('John: [email protected]')))
예제 #15
0
def email_retained(fixture):
    """The email address used when last logged in is always pre-populated on the Log in page."""

    browser = fixture.browser
    user = fixture.user

    browser.open('/')
    browser.click(XPath.link_with_text('Log in'))

    browser.type(XPath.input_labelled('Email'), '*****@*****.**')
    browser.type(XPath.input_labelled('Password'), 'topsecret')
    browser.click(XPath.button_labelled('Log in'))

    # Go away from the page, then back
    browser.click(XPath.link_with_text('Home'))
    browser.click(XPath.link_with_text('Log in'))

    # .. then the email is still pre-populated
    typed_value = browser.get_value(XPath.input_labelled('Email'))
    assert typed_value == '*****@*****.**'
예제 #16
0
def translations(fixture):
    """The user can choose between languages. The text for which translations exist change accordingly."""

    fixture.browser.open('/')
    vassert( fixture.browser.is_element_present(XPath.heading_with_text(1, "Addresses")) )
    vassert( fixture.browser.is_element_present(XPath.label_with_text("Name")) )

    #go to the the translated page
    fixture.browser.click(XPath.link_with_text('Afrikaans'))
    vassert( fixture.browser.is_element_present(XPath.heading_with_text(1, "Adresse")) )
    vassert( fixture.browser.is_element_present(XPath.label_with_text("Naam")) )
예제 #17
0
    def contents_when_navigating_the_page_numbers(self, fixture):
        """When navigating the range of page links, the currently displayed contents stay unchanged."""
        fixture.number_of_pages = 30
        fixture.max_page_links = 5
        fixture.reahl_server.set_app(fixture.wsgi_app)
        fixture.driver_browser.open('/')

        fixture.driver_browser.click(XPath.link_with_text('p2'))
        fixture.driver_browser.wait_for(fixture.container_contents_is, 'contents of page 2')
        fixture.driver_browser.click(XPath.link_starting_with_text('»'))
        fixture.driver_browser.wait_for(fixture.container_contents_is, 'contents of page 2')
예제 #18
0
 def active_state_of_page_links(self, fixture):
     """When choosing a page, the new page link is marked as active, without a server round-trip."""
     fixture.number_of_pages = 30
     fixture.max_page_links = 5
     fixture.reahl_server.set_app(fixture.wsgi_app)
     fixture.driver_browser.open('/')
     
     with fixture.driver_browser.no_load_expected_for('.pagination>*'):
         vassert( not fixture.is_marked_active('p2') )
         fixture.driver_browser.click(XPath.link_with_text('p2'))
         fixture.driver_browser.wait_for(fixture.is_marked_active, 'p2')
예제 #19
0
파일: test_table.py 프로젝트: diopib/reahl
def paging_through_data(fixture):
    """DataTable splits its items into different pages (between which a user can navigate), showing only the items of a particular page at a time."""
    fixture.reahl_server.set_app(fixture.wsgi_app)
    fixture.driver_browser.open('/')

    #click to last page
    fixture.driver_browser.click(XPath.link_starting_with_text('→'))
    fixture.driver_browser.click(XPath.link_with_text('9'))

    vassert(fixture.table_number_rows() == 2)
    vassert(fixture.get_table_row(1) == ['25', 'D'])
    vassert(fixture.get_table_row(2) == ['26', 'G'])

    #click to page 4
    fixture.driver_browser.click(XPath.link_starting_with_text('←'))
    fixture.driver_browser.click(XPath.link_with_text('4'))

    vassert(fixture.table_number_rows() == 3)
    vassert(fixture.get_table_row(1) == ['10', 'R'])
    vassert(fixture.get_table_row(2) == ['11', 'O'])
    vassert(fixture.get_table_row(3) == ['12', 'W'])
예제 #20
0
파일: test_form.py 프로젝트: diopib/reahl
def button_layouts_on_disabled_anchors(fixture):
    """Disabled A's are marked with a class so Bootstap can style them appropriately."""
    def can_write():
        return False

    anchor = A(fixture.view,
               href=Url('/an/href'),
               description='link text',
               write_check=can_write).use_layout(ButtonLayout())
    tester = WidgetTester(anchor)
    [rendered_anchor] = tester.xpath(XPath.link_with_text('link text'))
    vassert(rendered_anchor.attrib['class'] == 'btn disabled')
예제 #21
0
def test_parameterised1(fixture):
    browser = Browser(fixture.wsgi_app)
    browser.open('/')

    browser.click(XPath.link_with_text('Add an address'))
    browser.type(XPath.input_labelled('Name'), 'John')
    browser.type(XPath.input_labelled('Email'), '*****@*****.**')
    browser.click(XPath.button_labelled('Save'))

    vassert(browser.location_path == '/')
    browser.click(XPath.link_with_text('edit'))

    john = Session.query(parameterised1bootstrap.Address).one()
    vassert(browser.location_path == '/edit/%s' % john.id)
    browser.type(XPath.input_labelled('Name'), 'Johnny')
    browser.type(XPath.input_labelled('Email'), '*****@*****.**')
    browser.click(XPath.button_labelled('Update'))

    vassert(browser.location_path == '/')
    vassert(
        browser.is_element_present(
            XPath.paragraph_containing('Johnny: [email protected]')))
예제 #22
0
def clicking_on_multi_tab(fixture):
    """Clicking on a multitab just opens and closes its dropdown without affecting the current open tab."""
    fixture.reahl_server.set_app(fixture.wsgi_app)
    fixture.driver_browser.open('/')

    # Make tab 3 the active one
    fixture.driver_browser.click(XPath.link_with_text('tab 3 name'))
    vassert(
        fixture.driver_browser.wait_for(fixture.tab_is_active, 'tab 3 name'))
    vassert(
        fixture.driver_browser.wait_for(fixture.tab_contents_equals,
                                        '<p>tab 3 content</p>'))

    # Clicking on the multitab toggles the dropdown
    vassert(
        fixture.driver_browser.wait_for_element_not_visible(
            XPath.link_with_text('tab 2 name')))
    fixture.driver_browser.click(XPath.link_with_text('multitab name'))
    vassert(
        fixture.driver_browser.wait_for_element_visible(
            XPath.link_with_text('tab 2 name')))

    # - current active tab not changed
    vassert(
        fixture.driver_browser.wait_for(fixture.tab_is_active, 'tab 3 name'))
    vassert(
        fixture.driver_browser.wait_for(fixture.tab_contents_equals,
                                        '<p>tab 3 content</p>'))

    # Clicking on the multitab toggles the dropdown again
    fixture.driver_browser.click(XPath.link_with_text('multitab name'))

    # - current active tab not changed
    vassert(
        fixture.driver_browser.wait_for(fixture.tab_is_active, 'tab 3 name'))
    vassert(
        fixture.driver_browser.wait_for(fixture.tab_contents_equals,
                                        '<p>tab 3 content</p>'))
예제 #23
0
def workings_of_check_checkbox_button(fixture):
    """A CheckCheckBoxButton checks the checkbox on the original page when clicked."""

    fixture.reahl_server.set_app(fixture.wsgi_app)
    browser = fixture.driver_browser
    browser.open('/')

    browser.click(XPath.link_with_text('Home page'))
    browser.wait_for_element_visible(fixture.poppedup_contents)

    browser.click(XPath.button_labelled('Checkit'))
    browser.wait_for_element_not_visible(fixture.poppedup_contents)

    vassert( fixture.driver_browser.is_checked(XPath.input_labelled('a checkbox')) )
예제 #24
0
파일: test_table.py 프로젝트: diopib/reahl
def sorting(fixture):
    """By clicking on special links in the column header, the table is sorted according to that column - ascending or descending."""
    fixture.reahl_server.set_app(fixture.wsgi_app)
    fixture.driver_browser.open('/')

    #----- by default, not sorted
    vassert(not fixture.is_column_sorted(1, 'ascending'))
    vassert(not fixture.is_column_sorted(1, 'descending'))
    vassert(not fixture.is_column_sorted(2, 'ascending'))
    vassert(not fixture.is_column_sorted(2, 'descending'))

    #----- first click on column sorts ascending
    fixture.driver_browser.click(fixture.xpath_for_sort_link_for_column(1))
    vassert(fixture.is_column_sorted(1, 'ascending'))
    vassert(fixture.get_table_row(1) == ['1', 'T'])
    vassert(fixture.get_table_row(2) == ['2', 'H'])
    vassert(fixture.get_table_row(3) == ['3', 'E'])

    #----- sort ascending on alpha, the second column
    vassert(fixture.is_column_sorted(2, None))
    fixture.driver_browser.click(fixture.xpath_for_sort_link_for_column(2))
    vassert(fixture.is_column_sorted(2, 'ascending'))
    vassert(fixture.is_column_sorted(1, None))

    vassert(fixture.get_table_row(1) == ['22', 'A'])
    vassert(fixture.get_table_row(2) == ['9', 'B'])
    vassert(fixture.get_table_row(3) == ['7', 'C'])

    #----- sort descending on alpha, the second column
    fixture.driver_browser.click(fixture.xpath_for_sort_link_for_column(2))
    vassert(fixture.is_column_sorted(2, 'descending'))

    vassert(fixture.get_table_row(1) == ['23', 'Z'])
    vassert(fixture.get_table_row(2) == ['24', 'Y'])
    vassert(fixture.get_table_row(3) == ['15', 'X'])

    #----- sort order stays changed when paging
    fixture.driver_browser.click(XPath.link_with_text('4'))

    vassert(fixture.get_table_row(1) == ['4', 'Q'])
    vassert(fixture.get_table_row(2) == ['18', 'P'])
    vassert(fixture.get_table_row(3) == ['11', 'O'])

    #----- contents of the page you are on changes according to a new sort order
    fixture.driver_browser.click(fixture.xpath_for_sort_link_for_column(1))

    vassert(fixture.get_table_row(1) == ['10', 'R'])
    vassert(fixture.get_table_row(2) == ['11', 'O'])
    vassert(fixture.get_table_row(3) == ['12', 'W'])
예제 #25
0
def domain_exception(fixture):
    """Typing the wrong password results in an error message being shown to the user."""

    browser = fixture.browser
    user = fixture.user

    browser.open('/')
    browser.click(XPath.link_with_text('Log in'))

    browser.type(XPath.input_labelled('Email'), '*****@*****.**')
    browser.type(XPath.input_labelled('Password'), 'wrong password')
    browser.click(XPath.button_labelled('Log in'))

    assert browser.is_element_present(
        XPath.div_containing('The email/password given do not match'))
예제 #26
0
def domain_exception(fixture):
    """Typing the wrong password results in an error message being shown to the user."""

    browser = fixture.browser
    account = fixture.account

    browser.open('/')
    browser.click(XPath.link_with_text('Log in'))

    browser.type(XPath.input_labelled('Email'), '*****@*****.**')
    browser.type(XPath.input_labelled('Password'), 'wrong password')
    browser.click(XPath.button_labelled('Log in'))

    assert browser.is_element_present(
        XPath.div_containing('Invalid login credentials'))
예제 #27
0
def paging(fixture):
    """Clicking on a different page in the pager changes the addresses listed without triggering a page load."""

    fixture.reahl_server.set_app(fixture.wsgi_app)
    browser = fixture.browser

    browser.open('/')
    
    assert fixture.is_email_listed('*****@*****.**')
    assert not fixture.is_email_listed('*****@*****.**')

    with browser.no_page_load_expected():
        browser.click(XPath.link_with_text('2'))

    assert not fixture.is_email_listed('*****@*****.**')
    assert fixture.is_email_listed('*****@*****.**')
예제 #28
0
def i18n(fixture):
    fixture.start_example_app()
    fixture.driver_browser.open('/some_page')
    vassert(fixture.get_text_in_p() ==
            'This is a translated string. The current URL is "/some_page".')
    vassert(fixture.driver_browser.title == 'Translated example')
    fixture.driver_browser.capture_cropped_screenshot(
        fixture.new_screenshot_path('i18n1.png'))

    fixture.driver_browser.click(XPath.link_with_text('Afrikaans'))
    vassert(
        fixture.get_text_in_p() ==
        'Hierdie is \'n vertaalde string. Die huidige URL is "/af/some_page".')
    vassert(fixture.driver_browser.title == 'Vertaalde voorbeeld')
    fixture.driver_browser.capture_cropped_screenshot(
        fixture.new_screenshot_path('i18n2.png'))
예제 #29
0
def customising_dialog_buttons(fixture):
    """The buttons of the dialog can be customised."""

    fixture.reahl_server.set_app(fixture.wsgi_app)
    browser = fixture.driver_browser
    browser.open('/')

    button1_xpath = XPath.button_labelled('Butt1')
    button2_xpath = XPath.button_labelled('Butt2')
    fixture.driver_browser.open('/')

    browser.click(XPath.link_with_text('Home page'))
    browser.wait_for_element_visible(fixture.poppedup_contents)

    vassert( browser.is_element_present(button1_xpath) )
    vassert( browser.is_element_present(button2_xpath) )
예제 #30
0
def refreshing_widget(fixture):
    """Clicking on a link, refreshes the displayed text to indicate which link 
       was clicked, without triggering a page load."""

    fixture.reahl_server.set_app(fixture.wsgi_app)
    browser = fixture.browser

    browser.open('/')

    assert fixture.text_shows_selected(1)    
    assert not fixture.text_shows_selected(3)

    with browser.no_page_load_expected():
        browser.click(XPath.link_with_text('Select 3'))

    assert not fixture.text_shows_selected(1)    
    assert fixture.text_shows_selected(3)