def __init__(self, *args, **kwargs):
     unittest.TestCase.__init__(self, *args, **kwargs)
     self.__api_test = os.environ.get('api', False)
     self.TEST_CLASS = self
     self.__login = LoginPage()
     self.__register = RegisterPage()
     self.__dashboard = DashboardPage()
     self.__create_bot = CreateBotPage()
     self.__data = DataGenerateUtils()
Esempio n. 2
0
 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 __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")
Esempio n. 4
0
    def __init__(self, *args, **kwargs):
        super(TestAuthenticationPages, self).__init__(*args, **kwargs)
        self.__login = LoginPage()
        self.__register = RegisterPage()
        self.__forgot_password = ForgotPasswordPage()

        self.__data = DataGenerateUtils()
        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"
        self.eyes = Eyes()
        self.eyes.api_key = YAML_CONFIG.get("eyes_api_key")
Esempio n. 5
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))
 def __init__(self, *args, **kwargs):
     super(KnowledgeFeatureTests, self).__init__(*args, **kwargs)
     self.__data = DataGenerateUtils()
     self.__login = LoginPage()
     self.__create_bot = CreateBotPage()
     self.__register = RegisterPage()
     self.__appearance = AppearancePage()
     self.__knowledge_validation = KnowledgeValidation()
     self.__dashboard = DashboardPage()
     self.__knowledge = KnowledgePage()
     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_manual_faq_url")
     self.invalid_faq = YAML_CONFIG.get("stub_invalid_faq_url")
Esempio n. 7
0
 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"
Esempio n. 8
0
 def __init__(self, *args, **kwargs):
     super(AppearanceTests, 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.__chat_box_simulator = ClientSimulator()
     self.__loader = LoaderComponent()
     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 = self.__data.create_uuid_number()
     self.faq_url = YAML_CONFIG.get("stub_faq_url")
 def __init__(self, *args, **kwargs):
     super(TestConversationDuration, self).__init__(*args, **kwargs)
     self.__data = DataGenerateUtils()
     self.__create_bot = CreateBotPage()
     self.__register = RegisterPage()
     self.__appearance = AppearancePage()
     self.__integration = IntegrationPage()
     self.__create_bot_validation = CreateBotValidation()
     self.__html_file = HTMLFileUtils()
     self.__client_simulator = ClientSimulator()
     self.__conversation = ConversationPage()
     self.valid_email = self.__data.create_email()
     self.valid_username = self.__data.create_name()
     self.valid_password = self.__data.create_password()
     self.bot_name = self.__data.create_uuid_number()
     self.invalid_faq = YAML_CONFIG.get("stub_invalid_faq_url")
     self.integrated_page_path = ""
     self.root_path = os.path.dirname(
         os.path.dirname(os.path.abspath(__file__)))
     self.file_path = os.path.normpath(
         os.path.join(self.root_path, 'TestGUI', 'index.html'))
Esempio n. 10
0
 def __init__(self, *args, **kwargs):
     super(TestAdminPages, 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.__knowledge = KnowledgePage()
     self.__data_set = DataUtils()
     self.__faq_knowledge_data_table_component = FaqKnowledgeDataTableComponent(
     )
     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"
     self.eyes = Eyes()
     self.eyes.api_key = YAML_CONFIG.get("eyes_api_key")
     self.eyes.force_full_page_screenshot = True
     self.eyes.stitch_mode = StitchMode.CSS
class BaseTest(unittest.TestCase):
    API_PAY_LOAD = []
    GUI_SCREEN_SHOT = []

    def __init__(self, *args, **kwargs):
        unittest.TestCase.__init__(self, *args, **kwargs)
        self.__api_test = os.environ.get('api', False)
        self.TEST_CLASS = self
        self.__login = LoginPage()
        self.__register = RegisterPage()
        self.__dashboard = DashboardPage()
        self.__create_bot = CreateBotPage()
        self.__data = DataGenerateUtils()

    def setUp(self):
        self.API_PAY_LOAD = []
        if not self.is_api_test:
            DriverFactory.create_driver()

    def repeated_setup(self):
        pass

    def repeated_teardown(self):
        pass

    def tearDown(self):
        if not self.is_api_test:
            DriverFactory.dispose_driver()

    @property
    def is_api_test(self):
        return self.__api_test

    @is_api_test.setter
    def is_api_test(self, is_api_test):
        self.__api_test = is_api_test

    def sign_in_for_ui_test(self,
                            username=None,
                            email=None,
                            password=None,
                            bot_name=None,
                            faq_url=None,
                            is_debugging=False):
        try:
            if not is_debugging:
                # Generate data
                email = email or self.__data.create_email()
                username = username or self.__data.create_name()
                password = password or self.__data.create_password()
                bot_name = bot_name or self.__data.create_uuid_number()
                invalid_faq = faq_url or YAML_CONFIG.get(
                    "stub_invalid_faq_url")

                self.__register.open_register_page()
                self.__register.login_with_new_account(username, email,
                                                       password)
                self.__create_bot.wait_for_create_page()
                self.__create_bot.create_bot_with_data(bot_name, invalid_faq)
            else:
                email = email or YAML_CONFIG.get("email_for_debugging")
                password = password or YAML_CONFIG.get("pass_for_debugging")
                self.__login.login_with_account(email, password)
                self.__dashboard.wait_for_dashboard_page()

        except Exception as e:
            raise TestContextException(e)

    @staticmethod
    def assert_container(func, expected, actual):
        return lambda: func(expected, actual)
Esempio n. 12
0
class TestAuthenticationPages(BaseTest):
    def __init__(self, *args, **kwargs):
        super(TestAuthenticationPages, self).__init__(*args, **kwargs)
        self.__login = LoginPage()
        self.__register = RegisterPage()
        self.__forgot_password = ForgotPasswordPage()

        self.__data = DataGenerateUtils()
        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"
        self.eyes = Eyes()
        self.eyes.api_key = YAML_CONFIG.get("eyes_api_key")

    def setUp(self):
        super().setUp()

    def test_login_page_appearance(self):
        try:
            self.eyes.open(driver=self.__login.driver.core_driver,
                           app_name='sample_app',
                           test_name='Login Page',
                           viewport_size={'width': 1440, 'height': 887})
            self.__login.open_login_page()
            self.__login.wait_for_log_in_page()
            self.eyes.check_window("Default Login Page")
            self.__login.check_remember_me(False)
            self.eyes.check_window("Login Page without remember me")
            self.__login.login_with_account("", "")
            self.eyes.check_window("Login Page with error message")
        finally:
            res = self.eyes.close(raise_ex=True)
            print(res)
            self.eyes.abort_if_not_closed()

    def test_register_page_appearance(self):
        try:
            self.eyes.open(driver=self.__login.driver.core_driver,
                           app_name='sample_app',
                           test_name='Register Page',
                           viewport_size={'width': 1440, 'height': 887})
            self.__register.open_register_page()
            self.__register.wait_for_register_page()
            self.eyes.check_window("Default Register Page")
            self.__register.txt_email.click()
            self.eyes.check_window("Register with tips for email")
            self.__register.txt_password.click()
            self.eyes.check_window("Register with tips for password")
            self.__register.login_with_new_account("", "", "")
            self.eyes.check_window("Register with error message")
        finally:
            res = self.eyes.close(raise_ex=True)
            print(res)
            self.eyes.abort_if_not_closed()

    def test_forgot_password_page_appearance(self):
        try:
            self.eyes.open(driver=self.__login.driver.core_driver,
                           app_name='sample_app',
                           test_name='Forgot Password Page',
                           viewport_size={'width': 1440, 'height': 887})
            self.__forgot_password.open_forgot_password_page()
            self.__forgot_password.wait_for_forgot_password_page()
            self.eyes.check_window("Default Forgot password page")
            self.__forgot_password.submit_email("")
            self.eyes.check_window("Submit empty email")
            self.__forgot_password.submit_email("*****@*****.**")
            self.eyes.check_window("Submit with wrong email format")
            self.__forgot_password.submit_email(YAML_CONFIG.get("sample_app_user"))
            self.eyes.check_window("Submit successfully")
        finally:
            res = self.eyes.close(raise_ex=True)
            print(res)
            self.eyes.abort_if_not_closed()

    def tearDown(self):
        super().tearDown()
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()