예제 #1
0
 def set_log_level_restore():
     log_level_history = bi().get_variable_value("${LOG_LEVEL_HISTORY}")
     if not log_level_history:
         bi().set_log_level('INFO')
     else:
         last = log_level_history.pop()
         bi().set_log_level(last)
예제 #2
0
    def log_variable_to_file(name,
                             comment="",
                             output_file="Artifacts/variables.csv"):
        log_file = validate_create_artifacts_dir(output_file)
        logger.debug("Log to file " + log_file)
        fieldnames = [
            'Time', 'Test Case Name', 'Variable Name', 'Variable Value',
            'Comment'
        ]
        current_time = DateTime.get_current_date(
            result_format="%Y.%m.%d %H:%M:%S")
        test_case_name = str(bi().get_variable_value("${TEST_NAME}"))
        suite_name = str(bi().get_variable_value("${SUITE_NAME}"))
        variable_value = name

        # TODO
        # get variable name is not working
        # variable_name = _Variables._get_var_name(bi(),str(name))
        # bi().get_variable_value("${" + variable_name + "}", "Missing!!!")

        with open(log_file, 'a') as csv_file:
            writer_csv = csv.writer(csv_file, dialect='excel')
            if os.stat(log_file).st_size < 10:
                writer_csv.writerow(fieldnames)
            writer_csv.writerow([
                current_time, suite_name + "." + test_case_name, name,
                variable_value, comment
            ])
예제 #3
0
 def set_log_level_none():
     log_level_history = bi().get_variable_value("${LOG_LEVEL_HISTORY}")
     if log_level_history is None:
         log_level_history = []
     old = bi().set_log_level("None")
     log_level_history.append(old)
     bi().set_global_variable("${LOG_LEVEL_HISTORY}", log_level_history)
    def log_variable_to_file(self,
                             name,
                             comment="",
                             output_file="Artifacts/variables.csv"):
        log_file = validate_create_artifacts_dir(output_file)
        logger.debug("Log to file " + log_file)
        fieldnames = [
            "Time",
            "Test Case Name",
            "Variable Name",
            "Variable Value",
            "Comment",
        ]
        current_time = DateTime.get_current_date(
            result_format="%Y.%m.%d %H:%M:%S")
        test_case_name = str(bi().get_variable_value("${TEST_NAME}"))
        suite_name = str(bi().get_variable_value("${SUITE_NAME}"))
        variable_value = name

        with open(log_file, "a") as csv_file:
            writer_csv = csv.writer(csv_file, dialect="excel")
            if os.stat(log_file).st_size < 10:
                writer_csv.writerow(fieldnames)
            writer_csv.writerow([
                current_time,
                suite_name + "." + test_case_name,
                name,
                variable_value,
                comment,
            ])
 def click_element_extended_and_wait(
     self,
     locator,
     sleep,
     modifier=False,
     action_chain=False,
     timeout=None,
     error_msg=None,
     reason=None,
 ):
     sl().click_element_extended(locator, timeout, error_msg)
     bi().sleep(sleep, reason)
예제 #6
0
 def csv_writer_with_extra(self, *values):
     """
     Add extra params at beginning
     1. time of execution
     2. suite + test cases name
     """
     test_case_name = str(
         robot_instances.bi().get_variable_value("${TEST_NAME}"))
     suite_name = str(
         robot_instances.bi().get_variable_value("${SUITE_NAME}"))
     extra_list = list(values)
     extra_list.insert(0, suite_name + test_case_name)
     self.csv_writer_with_time(*extra_list)
 def element_attribute_should_be(self,
                                 locator,
                                 attribute,
                                 attribute_value_expected,
                                 msg=None,
                                 values=True):
     actual_value = sl().get_element_attribute(locator + "@" + attribute)
     # noinspection PyProtectedMember
     actual_value, attribute_value_expected = [
         bi()._convert_to_string(i)
         for i in (actual_value, attribute_value_expected)
     ]
     bi()._should_be_equal(actual_value, attribute_value_expected, msg,
                           values)
    def capture_page_screenshot_extension(
        self,
        prefix="",
        postfix="",
        add_time_stamp=True,
        add_test_case_name=True,
        add_file_path_to_list="${list of screenshots}",
        output_dir="Artifacts/Screenshots",
    ):
        output_dir_normalized = validate_create_artifacts_dir(output_dir)

        if add_time_stamp:
            current_time = " " + DateTime.get_current_date(
                result_format="%Y.%m.%d_%H.%M.%S")
        else:
            current_time = ""
        if add_test_case_name:
            test_case_name = bi().get_variable_value("${TEST_NAME}")
        else:
            test_case_name = ""

        output_file = (output_dir_normalized + "/" + prefix + test_case_name +
                       postfix + current_time + ".png")
        output_file_normalized = os.path.normpath(output_file)

        # sl()driver.get_screenshot_as_file(output_file_normalized)
        sl().capture_page_screenshot(output_file_normalized)

        results = bi().run_keyword_and_return_status("Variable Should Exist",
                                                     add_file_path_to_list)

        if not results:
            bi()._get_var_name(add_file_path_to_list)
            list_with_files = bi().create_list(output_file_normalized)
            bi().set_test_variable(add_file_path_to_list, list_with_files)
        else:
            list_with_files = bi().create_list(output_file_normalized)
            list_with_files = bi().run_keyword("Combine Lists",
                                               add_file_path_to_list,
                                               list_with_files)
            bi().set_test_variable(add_file_path_to_list, list_with_files)

        return output_file_normalized
 def click_element_extended_and_wait(self, locator, sleep, timeout=None, error_msg=None, reason=None):
     self.click_element_extended(locator, timeout, error_msg)
     bi().sleep(sleep, reason)