def configure_mock_calls_in_login(sl):
    """
    This method configures the stub calls in login() instance method in AdminLoginPage class.
    :param sl: the mocked selenium library object, to be used by AdminLoginPage
    :return: None
    """
    when(sl).input_text(locator=locator['admin_login_page']['username_field'],
                        text=get_variables()['CREDENTIALS']['valid_admin']
                        ['username']).thenReturn(None)

    when(sl).input_password(
        locator=locator['admin_login_page']['password_field'],
        password=get_variables()['CREDENTIALS']['valid_admin']
        ['password']).thenReturn(None)

    when(sl).click_element(
        locator=locator['admin_login_page']['login_button']).thenReturn(None)
示例#2
0
 def __init__(self, *args, **kwargs):
     super(AdminLoginPageUT, self).__init__(*args, **kwargs)
     self.credentials = get_variables()['CREDENTIALS']
示例#3
0
    def test_verify_admin_main_page(self):
        # configure the mock selenium library for verify_admin_main_page()'s calls
        expect(LibraryLoader.get_instance().sl).wait_until_element_is_enabled(
            locator=locator['admin_main_page']['logout']).thenReturn(None)

        expect(LibraryLoader.get_instance().sl).get_location().thenReturn(
            expected_admin_main_page_url)

        # configure mock calls in _verify_texts_on_admin_main_page()
        username = get_variables()['CREDENTIALS']['valid_admin']['username']
        expect(LibraryLoader.get_instance().sl).element_text_should_be(
            locator=locator['admin_main_page']['main_title'],
            expected=expected['admin_main_page']
            ['main_title_text']).thenReturn(None)

        # user navigation bar on the upper right of the page
        dynamic_user_tab_text = expected['admin_main_page'][
            'dynamic_user_tab_text'] % username.upper()
        expect(LibraryLoader.get_instance().sl).element_text_should_be(
            locator=locator['admin_main_page']['welcome_user_x'],
            expected=dynamic_user_tab_text).thenReturn(None)

        expect(LibraryLoader.get_instance().sl).element_text_should_be(
            locator=locator['admin_main_page']['view_site'],
            expected=expected['admin_main_page']['view_site_text']).thenReturn(
                None)

        expect(LibraryLoader.get_instance().sl).element_text_should_be(
            locator=locator['admin_main_page']['change_password'],
            expected=expected['admin_main_page']
            ['change_password_text']).thenReturn(None)

        expect(LibraryLoader.get_instance().sl).element_text_should_be(
            locator=locator['admin_main_page']['logout'],
            expected=expected['admin_main_page']['logout_text']).thenReturn(
                None)

        expect(LibraryLoader.get_instance().sl).element_text_should_be(
            locator=locator['admin_main_page']['site_administration'],
            expected=expected['admin_main_page']
            ['site_administration_text']).thenReturn(None)

        expect(LibraryLoader.get_instance().sl).element_text_should_be(
            locator=locator['admin_main_page']
            ['authentication_and_authorization'],
            expected=expected['admin_main_page']
            ['authentication_and_authorization_text']).thenReturn(None)

        expect(LibraryLoader.get_instance().sl).element_text_should_be(
            locator=locator['admin_main_page']['groups'],
            expected=expected['admin_main_page']['groups_text']).thenReturn(
                None)

        expect(LibraryLoader.get_instance().sl).element_text_should_be(
            locator=locator['admin_main_page']['users'],
            expected=expected['admin_main_page']['users_text']).thenReturn(
                None)

        expect(LibraryLoader.get_instance().sl).element_text_should_be(
            locator=locator['admin_main_page']['postings'],
            expected=expected['admin_main_page']['postings_text']).thenReturn(
                None)

        expect(LibraryLoader.get_instance().sl).element_text_should_be(
            locator=locator['admin_main_page']['blog_posts'],
            expected=expected['admin_main_page']
            ['blog_posts_text']).thenReturn(None)

        # the number of 'Add' buttons must be number_of_add_buttons
        expect(LibraryLoader.get_instance().sl).page_should_contain_element(
            locator=locator['admin_main_page']['add_button'],
            limit=number_of_add_buttons).thenReturn(None)

        # the number of 'Change' buttons must be number_of_change_buttons
        expect(LibraryLoader.get_instance().sl).page_should_contain_element(
            locator=locator['admin_main_page']['change_button'],
            limit=number_of_change_buttons).thenReturn(None)

        expect(LibraryLoader.get_instance().sl).element_text_should_be(
            locator=locator['admin_main_page']['recent_actions'],
            expected=expected['admin_main_page']
            ['recent_actions_text']).thenReturn(None)

        expect(LibraryLoader.get_instance().sl).element_text_should_be(
            locator=locator['admin_main_page']['my_actions'],
            expected=expected['admin_main_page']
            ['my_actions_text']).thenReturn(None)

        # configure mock calls in _verify_links_on_admin_main_page()
        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']['main_title'],
                attribute='href',
                expected=links['admin_main_page']
                ['main_title_link']).thenReturn(None)

        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']['view_site'],
                attribute='href',
                expected=links['admin_main_page']
                ['view_site_link']).thenReturn(None)

        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']['change_password'],
                attribute='href',
                expected=links['admin_main_page']
                ['change_password_link']).thenReturn(None)

        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']['logout'],
                attribute='href',
                expected=links['admin_main_page']['logout_link']).thenReturn(
                    None)

        # authentication and authorization section
        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']
                ['authentication_and_authorization'],
                attribute='href',
                expected=links['admin_main_page']
                ['authentication_and_authorization_link']).thenReturn(None)

        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']['groups'],
                attribute='href',
                expected=links['admin_main_page']['groups_link']).thenReturn(
                    None)

        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']['users'],
                attribute='href',
                expected=links['admin_main_page']['users_link']).thenReturn(
                    None)

        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']['add_group'],
                attribute='href',
                expected=links['admin_main_page']
                ['add_group_link']).thenReturn(None)

        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']['change_group'],
                attribute='href',
                expected=links['admin_main_page']
                ['change_group_link']).thenReturn(None)

        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']['add_user'],
                attribute='href',
                expected=links['admin_main_page']['add_user_link']).thenReturn(
                    None)

        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']['change_user'],
                attribute='href',
                expected=links['admin_main_page']
                ['change_user_link']).thenReturn(None)

        # postings section
        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']['postings'],
                attribute='href',
                expected=links['admin_main_page']['postings_link']).thenReturn(
                    None)

        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']['blog_posts'],
                attribute='href',
                expected=links['admin_main_page']
                ['blog_posts_link']).thenReturn(None)

        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']['add_blog_post'],
                attribute='href',
                expected=links['admin_main_page']
                ['add_blog_post_link']).thenReturn(None)

        expect(
            LibraryLoader.get_instance().sl).element_attribute_value_should_be(
                locator=locator['admin_main_page']['change_blog_post'],
                attribute='href',
                expected=links['admin_main_page']
                ['change_blog_post_link']).thenReturn(None)

        # CUT gets magically the mock instances (i.e. _loader & sl)
        admin_main_page = AdminMainPage()

        # method under test gets called
        admin_main_page.verify_admin_main_page(username=username)

        # Verifies that expectations set via expect are met
        # all registered objects will be checked.
        verifyNoUnwantedInteractions()