Exemplo n.º 1
0
class LoginFeatureTests(BaseTest):
    def __init__(self, *args, **kwargs):
        super(LoginFeatureTests, self).__init__(*args, **kwargs)
        self.__data = DataGenerateUtils()
        self.__login = LoginPage()
        self.__create_bot = CreateBotPage()
        self.__register = RegisterPage()
        self.__data_set = DataUtils()
        self.valid_email = self.__data.create_email()
        self.valid_username = self.__data.create_name()
        self.valid_password = self.__data.create_password()

    def test_login_unsuccessfully_due_to_blank_fields(self):
        accounts = self.__data_set.get_data(INVALID_LOGIN_DATA)
        expected_errors = [account[2] for account in accounts[1:]]
        actual_errors = []
        for account in accounts[1:]:
            email = account[0]
            password = account[1]
            self.__login.open_login_page()
            self.__login.login_with_account(email,
                                            password)
            actual_errors.append(self.__login.lbl_error_message.get_element_text())
        self.assertEqual(expected_errors, actual_errors,
                         "Assert Error : {0} != {1}".format(expected_errors, actual_errors))
        self.assertTrue(self.__login.txt_header_text.lower() in self.__login.driver.page_source.lower(),
                        "'{0}' text does not present in DOM".format(self.__login.txt_header_text))
        self.assertTrue(self.__login.path_page in self.__login.driver.current_url,
                        "{0} is not included in url".format(self.__login.path_page))
Exemplo n.º 2
0
class RegisterFeatureTests(BaseTest):
    def __init__(self, *args, **kwargs):
        super(RegisterFeatureTests, self).__init__(*args, **kwargs)
        self.__data = DataGenerateUtils()
        self.__register = RegisterPage()
        self.__create_bot = CreateBotPage()
        self.__data_set = DataUtils()
        self.valid_name = self.__data.create_name()
        self.valid_email = self.__data.create_email()
        self.valid_password = self.__data.create_password()

    def test_register_new_account_successful(self):
        self.__register.open_register_page()
        self.__register.login_with_new_account(self.valid_name,
                                               self.valid_email,
                                               self.valid_password)
        self.__create_bot.wait_for_create_page()
        self.assertTrue(
            self.__create_bot.txt_header_text.lower()
            in self.__create_bot.get_header_text().lower(),
            "Expect header '{0}' but '{1}' found".format(
                self.__create_bot.txt_header_text,
                self.__create_bot.get_header_text()))
        self.assertTrue(
            self.__create_bot.path_page in self.__register.driver.current_url,
            "Current page url {0}".format(self.__register.driver.current_url))

    def test_register_new_account_unsuccessful_with_invalid_inputs(self):
        accounts = self.__data_set.get_data(INVALID_REGISTER_DATA)
        expected_errors = [account[3] for account in accounts[1:]]
        errors = []
        for account in accounts[1:]:
            fullname = account[0]
            email = account[1]
            password = account[2]
            self.__register.open_register_page()
            self.__register.login_with_new_account(fullname, email, password)
            errors.append(self.__register.lbl_error_message.get_element_text())
        self.assertEqual(
            expected_errors, errors,
            "Assert Error : {0} != {1}".format(expected_errors, errors))
        self.assertTrue(
            self.__register.txt_header_text.lower()
            in self.__register.driver.page_source.lower(),
            "'{0}' does not present in DOM".format(
                self.__register.txt_header_text))
        self.assertTrue(
            self.__register.path_page in self.__register.driver.current_url,
            "{0} is not included in url".format(self.__register.path_page))
Exemplo n.º 3
0
class ChangePasswordTests(BaseTest):
    def __init__(self, *args, **kwargs):
        super(ChangePasswordTests, self).__init__(*args, **kwargs)
        self.__data = DataGenerateUtils()
        self.__login = LoginPage()
        self.__create_bot = CreateBotPage()
        self.__register = RegisterPage()
        self.__dashboard = DashboardPage()
        self.__appearance = AppearancePage()
        self.__create_bot_validation = CreateBotValidation()
        self.__drop_down_list = DropDownList()
        self.__change_password = ChangePasswordPage()
        self.__data_set = DataUtils()
        self.valid_email = self.__data.create_email()
        self.valid_username = self.__data.create_name()
        self.valid_password = self.__data.create_password()
        self.bot_name = "Test"
        self.invalid_faq = "google.com"

    def setUp(self):
        super().setUp()
        try:
            self.sign_in_for_ui_test(self.valid_username, self.valid_email,
                                     self.valid_password, self.bot_name,
                                     self.invalid_faq, False)
        finally:
            self.__change_password.open_change_password_page()

    def test_change_password_unsuccessfully_with_invalid_data(self):
        invalid_data = self.__data_set.get_data(
            INVALID_DATA_FOR_CHANGE_PASSWORD)
        for data in invalid_data:
            old_password = data[0]
            new_password = data[1]
            confirm_password = data[2]
            error_message = data[3]
            self.__change_password.change_password(old_password, new_password,
                                                   confirm_password)
            print(data)
            assert self.__change_password.get_error_message() == error_message, \
                f"Expect error message '{error_message}' but '{self.__change_password.get_error_message()}' is returned"
            assert self.__change_password.btn_submit.get_element_text() == "RETRY", \
                f"Expect button submit change to 'RETRY' but '{self.__change_password.btn_submit.get_element_text()}'"
        # Incorrect current password
        self.__change_password.change_password(self.valid_password + "123",
                                               "password", "password")
        assert self.__change_password.get_error_message() == "Your current password is not correct.", \
            f"Expect error message 'Your current password is not correct.' " \
            f"but '{self.__change_password.get_error_message()}' is returned"
        assert self.__change_password.btn_submit.get_element_text() == "RETRY", \
            f"Expect button submit change to 'RETRY' but '{self.__change_password.btn_submit.get_element_text()}'"

    def test_change_password_unsuccessfully_with_wrong_current_password(self):
        # Make old password become incorrect
        old_password = self.valid_password + "123"
        new_password = "******"
        expected_error_message = "Your current password is not correct."
        self.__change_password.change_password(old_password, new_password,
                                               new_password)
        actual_error_message = self.__change_password.get_error_message()
        assert actual_error_message == expected_error_message, \
            f"Expect '{expected_error_message}' but '{actual_error_message}' is displayed"
        assert self.__change_password.btn_submit.get_element_text() == "RETRY", \
            f"Expect button submit change to 'RETRY' but '{self.__change_password.btn_submit.get_element_text()}'"

    def test_change_password_successfully(self):
        new_password = "******"
        success_message = "Your password has been updated successfully."
        # Change Password
        self.__change_password.change_password(self.valid_password,
                                               new_password, new_password)
        # Verify
        actual_message = self.__change_password.get_success_message()
        assert actual_message == success_message, \
            f"Expect '{success_message}' but '{actual_message}' is displayed"
        self.__change_password.wait_for_button_back_to_dashboard_display()
        # Sign out
        self.__change_password.log_out()
        self.__login.wait_for_log_in_page()
        # Verify login successfully with new password
        self.__login.login_with_account(self.valid_email, new_password)
        self.__dashboard.wait_for_dashboard_page()
class CreateBotFeatureTests(BaseTest):
    def __init__(self, *args, **kwargs):
        super(CreateBotFeatureTests, self).__init__(*args, **kwargs)
        self.__data = DataGenerateUtils()
        self.__login = LoginPage()
        self.__create_bot = CreateBotPage()
        self.__register = RegisterPage()
        self.__appearance = AppearancePage()
        self.__create_bot_validation = CreateBotValidation()
        self.__drop_down_list = DropDownList()
        self.__data_set = DataUtils()
        self.valid_email = self.__data.create_email()
        self.valid_username = self.__data.create_name()
        self.valid_password = self.__data.create_password()
        self.faq_url = YAML_CONFIG.get("stub_faq_url")

    def setUp(self):
        super().setUp()
        self.__register.open_register_page()
        self.__register.login_with_new_account(self.valid_username,
                                               self.valid_email,
                                               self.valid_password)
        self.__create_bot.wait_for_create_page()

    def test_create_bot_unsuccessfully_with_invalid_inputs(self):
        bot_infos = self.__data_set.get_data(INVALID_BOT_INFO_DATA)
        expected_errors = [bot_info[2] for bot_info in bot_infos[1:]]
        actual_errors = []
        for bot_info in bot_infos[1:]:
            bot_name = bot_info[0]
            bot_url = bot_info[1]
            self.__create_bot.open_create_page()
            self.__create_bot.create_bot_with_data(bot_name, bot_url)
            actual_errors.append(
                self.__create_bot.lbl_error_message.get_element_text())
        self.assertEqual(expected_errors, actual_errors)

    @unittest.skip("Update logic with ignore for offline network")
    def test_create_bot_unsuccessfully_with_offline_connection(self):
        DriverFactory.get_driver().core_driver.set_network_conditions(
            offline=True, latency=5, throughput=500 * 1024)
        self.__create_bot.open_create_page()
        self.__create_bot.create_bot_with_data('Random Name',
                                               'www.katalon.com')
        self.assertEqual(
            self.__create_bot.lbl_error_message.get_element_text(),
            'Failed to fetch')

    def test_create_bot_successfully(self):
        bot_name = "Bot_name"
        website = self.faq_url
        self.__create_bot.open_create_page()
        self.__create_bot.create_bot_with_data(bot_name, website)
        print(self.__appearance.get_header_title_text())
        print(self.__appearance.get_expected_title(bot_name=bot_name))
        assert self.__appearance.get_header_title_text(
        ) == self.__appearance.get_expected_title(bot_name=bot_name)
        self.__create_bot_validation.wait_and_verify_notification_message()
        self.__create_bot_validation.should_init_correct_total_faq_questions(
            self.valid_email, bot_name)
        self.__create_bot_validation.should_init_correct_question_data()

    def test_create_bot_with_existed_bot_name_successfully(self):
        new_bot_name = "Bot_name"
        new_bot_website = "www.google.com"
        # Create a bot
        self.test_create_bot_successfully()
        # Open create bot page again
        self.__create_bot.open_create_page()
        self.__create_bot.create_bot_with_data(new_bot_name, new_bot_website)
        # Verify that new bot name is displayed
        self.__create_bot_validation.new_bot_should_be_current_selected_bot(
            new_bot_name, new_bot_website)
        self.__create_bot_validation.wait_and_verify_notification_message()
        self.__create_bot_validation.should_init_correct_total_faq_questions(
            self.valid_email, new_bot_name)
        self.__create_bot_validation.should_init_correct_question_data()

    def test_create_bot_with_existed_website_successfully(self):
        new_bot_name = "Another name"
        new_bot_website = self.faq_url
        # Create a bot
        self.test_create_bot_successfully()
        # Open create bot page again
        self.__create_bot.open_create_page()
        self.__create_bot.create_bot_with_data(new_bot_name, new_bot_website)
        # Verify that new bot name is displayed
        self.__create_bot_validation.new_bot_should_be_current_selected_bot(
            new_bot_name, new_bot_website)
        self.__create_bot_validation.wait_and_verify_notification_message()
        self.__create_bot_validation.should_init_correct_total_faq_questions(
            self.valid_email, new_bot_name)
        self.__create_bot_validation.should_init_correct_question_data()