Пример #1
0
    def set_str_variable(key: str, data_object: DataObject = None) -> str:
        value = InitUtils.get_argument(key)

        if (value is not None and not value) or value is None:
            value = data_object.get_var(key)
        else:
            data_object.set_value(key, value)

        return value
Пример #2
0
    def set_api_url(self, config_data: DataObject):
        if self.__api_url is None:
            __server_url = os.environ.get(AutomationConstants.API_URL)

            if __server_url is not None and __server_url:
                self.__api_url = __server_url
                config_data.set_value(AutomationConstants.API_URL, self.__api_url)
            else:
                self.__api_url = config_data.get_var(AutomationConstants.API_URL)
        else:
            config_data.set_value(AutomationConstants.API_URL, self.__api_url)
Пример #3
0
    def set_main_driver(self, config_data: DataObject):
        if self.__main_driver is None:
            self.__main_driver = InitUtils.get_main_driver_from_properties()

            if (self.__main_driver is None or not self.__main_driver) and config_data is not None \
                    and config_data.get_var(AutomationConstants.MAIN_DRIVER) is not None \
                    and config_data.get_var(AutomationConstants.MAIN_DRIVER):
                self.__main_driver = config_data.get_var(AutomationConstants.MAIN_DRIVER)

            if self.__main_driver is None or not self.__main_driver:
                self.__main_driver = 'api'
Пример #4
0
    def __init__(self, key=None, data=None):
        if key is not None and data is not None:
            self.__key = key

            if isinstance(data, DataObject):
                self.add_data(key, data)
            elif isinstance(data, dict):
                self.add_data(key, DataObject(data))
Пример #5
0
    def set_bool_variable(key: str, data_object: DataObject = None) -> bool:
        value = InitUtils.get_argument(key)

        if value is not None and (not value or value.lower() == "true"):
            value = True
        elif value is not None and value is not '':
            value = False

        if value is None:
            value = data_object.get_var(key)

            if str(value).lower() == "true":
                value = True
            else:
                value = False
        else:
            data_object.set_value(key, value)

        return bool(value)
Пример #6
0
    def _translate_or_format(self, text):
        if self._translation_file:
            translation_object: DataObject = DataObject(
                FileUtils.file_to_m_data(AutomationConstants.RESOURCES_FOLDER + self._translation_file))

            if translation_object.get_var(text):
                result = translation_object.get_var(text)
            else:
                result = self._snake_case_to_natural(text)
        else:
            result = self._snake_case_to_natural(text)

        return result
Пример #7
0
    def set_suite_var_row(self, row_key: str, key: str, value: str):
        value_set: bool = False

        for data_key in self.__suite_data.get_key_set():
            if self.__suite_data.get_data(data_key).get_row(row_key) is not None:
                self.set_suite_var_suite(data_key, row_key, key, value)
                value_set = True
                break

        if not value_set:
            if self.get_suite_data(AutomationConstants.SUITE_DATA) is None:
                self.add_suite_data(DataObject().add_row('row').add_row(row_key).set_key(row_key),
                                    AutomationConstants.SUITE_DATA)
            self.get_suite_data(AutomationConstants.SUITE_DATA).set_value(row_key, key, value)
Пример #8
0
    def __init__(self, browser, config_data=DataObject()):
        self.__browser = browser
        self.__id = '0'
        self.__report_path = None
        self.__ip = "localhost"
        self.__port = "4444"
        self.__browser_type = None
        self.__emulation_browser = None
        self.__driver_type = "WEB"
        self.__device_name = None
        self.__device_platform = None
        self.__remote = False
        self.__desktop = True
        self.__driver: webdriver.Remote = None
        self.__driver_path = None
        self.__maximize = True
        self.__wait_for_page = True
        self.__wait_for_angular = True
        self.__wait_for_jquery = False
        self.__short_wait = 3
        self.__implicit_timeout = 50
        self.__script_timeout = 50
        self.__page_load_timeout = 50
        self.__small_window_limit = 1025
        self.__default_window_height = 768
        self.__default_window_width = 1366
        self.__download_drivers = True
        self.__plugin_files = []
        self.__headless = False
        self.__language = None
        self.__use_proxy = False
        self.__driver_type = AutomationConstants.WEB
        self.__config_data = config_data
        self.__logger: DebugLogger = DebugLogger()

        self.__initialize_base_variables(browser)
Пример #9
0
    def get_result_matrix_from_test_data(test_data: DataObject, test_variables: []):
        contains_browser = test_data.get_row().__contains__(AutomationConstants.BROWSER)
        contains_device = test_data.get_row().__contains__(AutomationConstants.PLATFORM)
        test_variables = ArrayUtils.remove_element_from_array(test_variables, AutomationConstants.BROWSER)
        test_variables = ArrayUtils.remove_element_from_array(test_variables, AutomationConstants.DEVICE)
        test_variables = ArrayUtils.remove_element_from_array(test_variables, AutomationConstants.PLATFORM)
        result_matrix = ([[None] * (len(test_variables) + 3 + (1 if contains_browser or contains_device else 0))]
                         * (test_data.size() + 1))

        for j in range(len(test_variables)):
            result_matrix[0][j] = test_variables[j]

        if contains_device or contains_browser:
            result_matrix[0][len(result_matrix[0]) - 4] = AutomationConstants.BROWSER

        result_matrix[0][len(result_matrix[0]) - 3] = "result"
        result_matrix[0][len(result_matrix[0]) - 2] = "time"
        result_matrix[0][len(result_matrix[0]) - 1] = "exception"

        for i in range(1, len(result_matrix)):
            array_aux = [None] * (len(test_variables) + 3 + (1 if contains_browser or contains_device else 0))

            for j in range(len(test_variables)):
                array_aux[j] = test_data.get_var(test_variables[j], str(i - 1))

            if contains_browser or contains_device:
                browser = test_data.get_var(AutomationConstants.BROWSER, str(i - 1))
                browser = test_data.get_var(AutomationConstants.PLATFORM, str(i - 1)) \
                    if not contains_browser else browser

                array_aux[len(array_aux) - 4] = browser

            array_aux[len(array_aux) - 3] = AutomationConstants.TEST_UNDONE
            array_aux[len(array_aux) - 2] = "0.0"
            array_aux[len(array_aux) - 1] = "None"

            result_matrix[i] = array_aux

        return result_matrix
Пример #10
0
    def add_dm_data_from_file(self, key: str, file_name: str):
        from main.automation.model.utils.FileUtils import FileUtils

        self.add_data(key, DataObject(FileUtils.csv_file_to_dm_data(file_name)))
        pass
Пример #11
0
    def matrix_to_d_m_data(matrix: list) -> DataObject:
        from main.automation.model.utils.FileUtils import FileUtils

        return DataObject(
            FileUtils.csv_string_to_m_data(
                ArrayUtils.matrix_to_string(matrix, '\n', ';')))
Пример #12
0
 def set_max_tries(self, config_data: DataObject):
     if StringUtils.is_number(InitUtils.set_str_variable(AutomationConstants.MAX_TRIES, config_data)):
         self.__max_tries = config_data.get_var(AutomationConstants.MAX_TRIES)
     else:
         config_data.set_value(AutomationConstants.MAX_TRIES, str(self.__max_tries))
Пример #13
0
    def add_suite_data_file(self, file_path: str, data_key: str):
        if file_path is not None and not os.path.isabs(file_path):
            file_path = AutomationConstants.RESOURCES_FOLDER + file_path

        data_object: DataObject = DataObject(FileUtils.file_to_dm_data(file_path))
        self.add_suite_data(data_object, data_key)
Пример #14
0
    def set_suite_var(self, key: str, value: str):
        if self.get_suite_data(AutomationConstants.SUITE_DATA) is None:
            self.add_suite_data(DataObject().add_row('row'), AutomationConstants.SUITE_DATA)

        self.get_suite_data(AutomationConstants.SUITE_DATA).set_value(value_key=key, value=value)