Exemple #1
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")
class ConversationPage(BasePage):
    path_page = "/admin/conversations"
    list_conversations_container = ElementFactory.get_list_element(
        by=By.XPATH,
        locator="//*[contains(@class, 'list') and contains(@class,'conversations')]//*[contains(@class,'item')]",
        element_cls=BaseElement
    )

    def __init__(self):
        self.__loader_component = LoaderComponent()

    def open_conversation_page(self):
        self.open_page(path=self.path_page)

    def get_last_message(self, conversation_index=0):
        self.__loader_component.wait_for_component_invisible()
        txt_last_message = self.list_conversations_container[conversation_index].find_element(
            by=By.TAG_NAME,
            value="abbr",
        )
        return txt_last_message.text
 def __init__(self):
     self.__loader_component = LoaderComponent()
 def __init__(self):
     self.__db_helper = DatabaseHelper(DatabaseType.MONGO_DB).database_query
     self.__loader_component = LoaderComponent()
class CreateBotPage(BasePage):
    timeout = 10
    path_page = "/admin/manage_account/create_bot"
    txt_website_url = ElementFactory.get_element_until(
        by=By.ID,
        locator="website-input",
        wait_type=EC.visibility_of_element_located,
        element_cls=SeleniumElement)
    txt_bot_name = ElementFactory.get_element_until(
        by=By.ID,
        locator="chatbot-name-input",
        wait_type=EC.visibility_of_element_located,
        element_cls=SeleniumElement)
    btn_create_bot = ElementFactory.get_element_until(
        by=By.ID,
        locator="create-button",
        wait_type=EC.visibility_of_element_located,
        element_cls=SeleniumElement)

    lbl_error_message = ElementFactory.get_element(
        by=By.XPATH,
        locator="//button[@id='create-button']/../span",
        element_cls=SeleniumElement)
    # Should move to common page object
    txt_bottom_left_noti = ElementFactory.get_element(
        by=By.CSS_SELECTOR,
        locator="#root div.notifications-wrapper div.notification-message",
        element_cls=SeleniumElement)

    txt_header = ElementFactory.get_element_until(
        by=By.CSS_SELECTOR,
        locator="h2.header",
        wait_type=EC.visibility_of_element_located,
        element_cls=BaseElement)

    def __init__(self):
        self.__db_helper = DatabaseHelper(DatabaseType.MONGO_DB).database_query
        self.__loader_component = LoaderComponent()

    @property
    def txt_header_text(self):
        return "Create your virtual assistant"

    def get_header_text(self) -> str:
        return self.txt_header.get_element_text()

    def open_create_page(self):
        self.open_page(self.path_page)

    def create_bot_with_data(self, bot_name, website_url):
        self.input_bot_info_with_data(bot_name, website_url)
        self.click_create_bot_button()
        self.__loader_component.wait_for_component_invisible(60)

    def input_bot_info_with_data(self, bot_name, website_url):
        self.txt_bot_name.send_keys(bot_name)
        self.txt_website_url.send_keys(website_url)

    def click_create_bot_button(self):
        self.btn_create_bot.click()

    def wait_for_create_page(self):
        self.wait_for_page(self.path_page, self.timeout)

    def get_bot_data_via_user_email(self, user_email):
        return self.__db_helper.get_item_in_collection(
            "Bot", {"creators.0.email": user_email})

    def get_bot_data_via_user_email_and_bot_name(self, user_email, bot_name):
        return self.__db_helper.get_item_in_collection("Bot", {
            "creators.0.email": user_email,
            "name": bot_name
        })

    def get_list_question_via_bot_id(self, bot_id):
        return self.__db_helper.get_list_item_in_collection(
            "Qna", {"botId": bot_id})
Exemple #6
0
class AppearanceTests(BaseTest):
    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 setUp(self):
        super().setUp()
        try:
            self.sign_in_for_ui_test(self.valid_username, self.valid_email,
                                     self.valid_password, self.bot_name,
                                     self.faq_url, False)
            self.__appearance.open_appearance_page()
            self.__appearance.wait_for_appearance_page()
        except Exception as e:
            raise TestContextException(e)

    def test_change_chat_bot_title_successfully(self):
        new_title = "test_debug"
        print(self.__appearance.txb_title.get_element_text())
        self.__appearance.change_bot_title(new_title)
        self.__appearance.driver.core_driver.refresh()
        self.__appearance.wait_for_appearance_page()
        assert self.__appearance.txb_title.get_element_text_value() == new_title, \
            f"Title is '{self.__appearance.txb_title.get_element_text_value()}' instead of '{new_title}'"

    def test_change_bot_name_successfully(self):
        new_name = "test_debug"
        self.__appearance.change_bot_name(new_name)
        self.__appearance.driver.core_driver.refresh()
        self.__appearance.wait_for_appearance_page()
        assert self.__appearance.txb_bot_name.get_element_text_value() == new_name, \
            f"Bot name is '{self.__appearance.txb_bot_name.get_element_text_value()}' instead of '{new_name}'"

    def test_update_avatar_successfully(self):
        valid_avatar = get_valid_avatar()
        last_avatar_src = self.__appearance.img_avatar.get_element_attribute(
            "src")
        self.__appearance.update_avatar(valid_avatar)
        self.__loader.wait_for_component_invisible()
        current_avatar_src = self.__appearance.img_avatar.get_element_attribute(
            "src")
        assert current_avatar_src != last_avatar_src, "Avatar has not been changed"
        assert self.__chat_box_simulator.get_bot_avatar_source() != last_avatar_src, \
            "Avatar in simulation has not been changed"

    def test_update_avatar_with_invalid_size_unsuccessfully(self):
        error_message = "File size must be less than 1MB."
        list_invalid_file = get_list_invalid_size_avatar()
        last_avatar_src = self.__appearance.img_avatar.get_element_attribute(
            "src")
        for value in list_invalid_file:
            self.upload_avatar_and_verify_error_message(value, error_message)
            self.verify_avatar_source_does_not_change(last_avatar_src)

    def test_update_avatar_with_invalid_file_type_unsuccessfully(self):
        error_message = "This file type is not supported."
        list_invalid_file = get_list_invalid_type_avatar()
        last_avatar_src = self.__appearance.img_avatar.get_element_attribute(
            "src")
        for value in list_invalid_file:
            self.upload_avatar_and_verify_error_message(value, error_message)
            self.verify_avatar_source_does_not_change(last_avatar_src)

    def test_update_avatar_with_invalid_format_unsuccessfully(self):
        error_message = "Uploaded file is not a valid image."
        list_invalid_file = get_list_invalid_format_avatar()
        last_avatar_src = self.__appearance.img_avatar.get_element_attribute(
            "src")
        for value in list_invalid_file:
            self.upload_avatar_and_verify_error_message(value, error_message)
            self.verify_avatar_source_does_not_change(last_avatar_src)

    def upload_avatar_and_verify_error_message(self, file_path, error_message):
        self.__appearance.driver.core_driver.refresh()
        self.__appearance.wait_for_appearance_page()
        self.__appearance.img_avatar.click()
        self.__appearance.input_ava.send_keys(file_path)
        actual_error_message = self.__appearance.lbl_error_message_of_upload_avatar.get_element_text(
        )
        assert actual_error_message == error_message, \
            f"'{actual_error_message}' is displayed when upload invalid format avatar {file_path}"

    def verify_avatar_source_does_not_change(self, current_avatar_src):
        self.__appearance.btn_cancel_upload_avatar.click()
        self.__appearance.driver.core_driver.refresh()
        self.__appearance.wait_for_appearance_page()
        actual_avatar_src = self.__appearance.img_avatar.get_element_attribute(
            "src")
        assert actual_avatar_src == current_avatar_src, "Avatar has been changed"

    @unittest.skip("TODO TEST")
    def test_integration_website_reflect_change_on_appearance(self):
        pass