예제 #1
0
class Test_001_Login:
    baseURL = ReadConfig.get_application_url()
    username = ReadConfig.get_username()
    password = ReadConfig.get_password()

    logger = LogGen.loggen()

    path_to_screenshots = os.path.join('.', 'screenshots')

    def test_home_page_title(self, setup):
        self.logger.info("***Test_001_Login***")
        self.logger.info("***Verifying Home Page Title***")
        self.driver = setup
        self.driver.get(self.baseURL)
        actual_title = self.driver.title
        if actual_title == "Your store. Login":
            assert True
            self.logger.info("*** Home page title test is passed ***")
            self.driver.close()
        else:
            path_to_failed_home_page_title_test = os.path.join(self.path_to_screenshots,
                                                               'test_home_page_title_failed.png')
            self.driver.save_screenshot(path_to_failed_home_page_title_test)
            self.logger.error("*** Home page title test is failed ***")
            self.driver.close()
            assert False

    def test_login(self, setup):
        self.logger.info("***Verifying Login test***")
        self.driver = setup
        self.driver.get(self.baseURL)
        self.lp = LoginPage(self.driver)
        self.lp.set_user_name(self.username)
        self.lp.set_password(self.password)
        self.lp.click_login_button()
        actual_title = self.driver.title
        if actual_title == "Dashboard / nopCommerce administration":
            self.logger.info("*** Login test is passed ***")
            self.driver.close()
            assert True
        else:
            path_to_failed_login_test = os.path.join(self.path_to_screenshots, 'test_login_failed.png')
            self.driver.save_screenshot(path_to_failed_login_test)
            self.logger.error("*** Login test is failed ***")
            self.driver.close()
            assert False
예제 #2
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))
예제 #3
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.")
예제 #4
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.")
예제 #5
0
class Test_002_DDT_Login:
    baseURL = ReadConfig.get_application_url()

    path_to_excel_data = os.path.join('.', 'test_data', 'login_data.xlsx')

    logger = LogGen.loggen()

    def test_login_ddt(self, setup):
        self.logger.info("***Test_002_DDT_Login***")
        self.logger.info("***Verifying Login DDT test***")
        self.driver = setup
        self.driver.get(self.baseURL)
        self.lp = LoginPage(self.driver)
        self.rows = excel_utils.get_row_count(self.path_to_excel_data, 'Лист1')
        print('Number of Rows i a Excel: ', self.rows)

        status_list = []

        for row in range(2, self.rows + 1):
            self.user = excel_utils.read_data(self.path_to_excel_data, 'Лист1',
                                              row, 1)
            self.password = excel_utils.read_data(self.path_to_excel_data,
                                                  'Лист1', row, 2)
            self.exp = excel_utils.read_data(self.path_to_excel_data, 'Лист1',
                                             row, 3)

            self.lp.set_user_name(self.user)
            self.lp.set_password(self.password)
            self.lp.click_login_button()
            time.sleep(2)

            actual_title = self.driver.title
            expected_title = "Dashboard / nopCommerce administration"

            if actual_title == expected_title:
                if self.exp == 'Pass':
                    self.logger.info('*** Passed ***')
                    self.lp.click_logout_button()
                    status_list.append('Pass')
                elif self.exp == 'Fail':
                    self.logger.error('*** Failed ***')
                    self.lp.click_logout_button()
                    status_list.append('Fail')
            elif actual_title != expected_title:
                if self.exp == 'Pass':
                    self.logger.error('*** Failed ***')
                    status_list.append('Fail')
                elif self.exp == 'Fail':
                    self.logger.info('*** Passed ***')
                    status_list.append('Pass')

        if 'Fail' not in status_list:
            self.logger.info('*** Login DDT test is passed ***')
            self.driver.close()
            assert True
        else:
            self.logger.error('*** Login DDT test is failed ***')
            self.driver.close()
            assert False

        self.logger.info('*** End of Login DDT Test ***')
        self.logger.info('\n')