예제 #1
0
    def test_successful_login_clicking_button(self):
        """
        Tests the login functionality of www.hudl.com considering the user clicked on the Login button
        to perform the action.
        """

        main_page = MainPage(self.driver)
        self.assertTrue(
            main_page.is_title_matches(),
            "The title of the Hudl main page was different from the expected. Found: {}, Expected: {}"
            .format(self.driver.title, main_page.MAIN_PAGE_TITLE))

        # Clicks on the Login button to be redirected to the login page
        main_page.click_login_button()

        login_page = LoginPage(self.driver)

        self.assertTrue(
            login_page.is_title_matches(),
            "The title of the Hudl login page was different from the expected. Found: {}, Expected: {}"
            .format(self.driver.title, login_page.LOGIN_PAGE_TITLE))

        # Sets the text of the email input to the user's email
        login_page.email_text_element = login_data.VALID_EMAIL

        # Sets the text of the password input to the user's password
        login_page.pwd_text_element = login_data.VALID_PASSWORD

        login_page.click_login_button()

        logged_in_page = LoggedInPage(self.driver)

        # Verifies if the user menu is visible
        self.assertTrue(
            logged_in_page.is_logged_in(),
            "The user wasn't logged in after clicking the Login button.")

        # Verifies if the display name present on the user menu matches the expected
        self.assertTrue(
            logged_in_page.is_display_name_matches(),
            "The display name don't match the expected. Found: {}, Expected: {}"
            .format(logged_in_page.display_name_text_element,
                    login_data.DISPLAY_NAME))

        print("\nSuccessfully logged in as {}!".format(
            logged_in_page.display_name_text_element))
예제 #2
0
    def test_unsuccessful_login_invalid_password(self):
        """
        Tests the login functionality of www.hudl.com considering the user pressed the enter key to perform the action.
        """

        main_page = MainPage(self.driver)
        self.assertTrue(
            main_page.is_title_matches(),
            "The title of the Hudl main page was different from the expected. Found: {}, Expected: {}"
            .format(self.driver.title, main_page.MAIN_PAGE_TITLE))

        # Clicks on the Login button to be redirected to the login page
        main_page.click_login_button()

        login_page = LoginPage(self.driver)

        self.assertTrue(
            login_page.is_title_matches(),
            "The title of the Hudl login page was different from the expected. Found: {}, Expected: {}"
            .format(self.driver.title, login_page.LOGIN_PAGE_TITLE))

        # Sets the text of the email input to the user's email
        login_page.email_text_element = login_data.VALID_EMAIL

        # Sets the text of the password input to the user's password
        login_page.pwd_text_element = login_data.INVALID_PASSWORD

        login_page.click_login_button()

        # Verifies if the error container is visible
        self.assertTrue(
            login_page.is_error_container_visible(),
            "No error message was shown when trying to login with "
            "empty credential fields.")
        # Verify if the visible error message matches the expected
        self.assertTrue(
            login_page.is_error_message_matches(),
            "The error message displayed to the user was different "
            "from the expected.")
예제 #3
0
    def test_unsuccessful_login_empty_fields(self):
        """
        Tests the login functionality of www.hudl.com considering the user try to login with empty fields.
        """

        main_page = MainPage(self.driver)
        self.assertTrue(
            main_page.is_title_matches(),
            "The title of the Hudl main page was different from the expected. Found: {}, Expected: {}"
            .format(self.driver.title, main_page.MAIN_PAGE_TITLE))

        # Clicks on the Login button to be redirected to the login page
        main_page.click_login_button()

        login_page = LoginPage(self.driver)

        self.assertTrue(
            login_page.is_title_matches(),
            "The title of the Hudl login page was different from the expected. "
            "Found: {}, Expected: {}".format(self.driver.title,
                                             login_page.LOGIN_PAGE_TITLE))

        login_page.clear_credential_fields()

        login_page.click_login_button()

        # Verifies if the error container is visible
        self.assertTrue(
            login_page.is_error_container_visible(),
            "No error message was shown when trying to login with "
            "empty credential fields.")
        # Verify if the visible error message matches the expected
        self.assertTrue(
            login_page.is_error_message_matches(),
            "The error message displayed to the user was different "
            "from the expected.")