From 71d630b41e74341af33d26abf8b22845685413cc Mon Sep 17 00:00:00 2001 From: LEANDRO L MONTEIRO <60761500+98llm@users.noreply.github.com> Date: Wed, 7 Aug 2024 14:31:21 -0300 Subject: [PATCH 01/25] Update version.py --- tir/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tir/version.py b/tir/version.py index e3ed11150..1e65a66a5 100644 --- a/tir/version.py +++ b/tir/version.py @@ -1 +1 @@ -__version__ = '1.20.22' +__version__ = '1.20.23rc1' From 218f846c0ff33329fce4acbbd04ed0809a49d901 Mon Sep 17 00:00:00 2001 From: LEANDRO L MONTEIRO <60761500+98llm@users.noreply.github.com> Date: Wed, 7 Aug 2024 14:31:58 -0300 Subject: [PATCH 02/25] Update install_package.cmd --- scripts/install_package.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_package.cmd b/scripts/install_package.cmd index ede3804de..28eb2a7cd 100644 --- a/scripts/install_package.cmd +++ b/scripts/install_package.cmd @@ -13,5 +13,5 @@ taskkill /f /im chromedriver.exe echo ------------------------- echo Installing project... echo ------------------------- -pip install -U dist/tir_framework-1.20.22.tar.gz +pip install -U dist/tir_framework-1.20.23rc1.tar.gz pause >nul | set/p = Press any key to exit ... From e8e7a68277c972ded19905bdad5d31af5b1a089f Mon Sep 17 00:00:00 2001 From: renanllisboa Date: Thu, 8 Aug 2024 16:21:44 -0300 Subject: [PATCH 03/25] fix initial_time log class. --- tir/technologies/webapp_internal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tir/technologies/webapp_internal.py b/tir/technologies/webapp_internal.py index c9b2273f4..ccdabad5e 100644 --- a/tir/technologies/webapp_internal.py +++ b/tir/technologies/webapp_internal.py @@ -7872,7 +7872,7 @@ def log_error(self, message, new_log_line=True, skip_restart=False): self.message = log_message self.expected = False self.log.seconds = self.log.set_seconds(self.log.initial_time) - self.initial_time = datetime.today() + self.log.initial_time = datetime.today() self.log.testcase_seconds = self.log.set_seconds(self.log.testcase_initial_time) self.log.ct_method, self.log.ct_number = self.log.ident_test() @@ -8453,7 +8453,7 @@ def assert_result(self, expected, script_message): self.expected = expected log_message = f"{self.log.ident_test()[1]} - " self.log.seconds = self.log.set_seconds(self.log.initial_time) - self.initial_time = datetime.today() + self.log.initial_time = datetime.today() if self.config.smart_test: self.log.log_exec_file() From 84425963b773456d4620327432fb6b7601aaa1a5 Mon Sep 17 00:00:00 2001 From: LEANDRO L MONTEIRO <60761500+98llm@users.noreply.github.com> Date: Mon, 19 Aug 2024 16:01:57 -0300 Subject: [PATCH 04/25] Update version.py --- tir/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tir/version.py b/tir/version.py index 1e65a66a5..bbc7a7119 100644 --- a/tir/version.py +++ b/tir/version.py @@ -1 +1 @@ -__version__ = '1.20.23rc1' +__version__ = '1.20.23rc2' From c7b08a418b1226a85c80c1bd8b1965bb8f9535ec Mon Sep 17 00:00:00 2001 From: LEANDRO L MONTEIRO <60761500+98llm@users.noreply.github.com> Date: Mon, 19 Aug 2024 16:02:47 -0300 Subject: [PATCH 05/25] Update install_package.cmd --- scripts/install_package.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_package.cmd b/scripts/install_package.cmd index 28eb2a7cd..a397ec1a2 100644 --- a/scripts/install_package.cmd +++ b/scripts/install_package.cmd @@ -13,5 +13,5 @@ taskkill /f /im chromedriver.exe echo ------------------------- echo Installing project... echo ------------------------- -pip install -U dist/tir_framework-1.20.23rc1.tar.gz +pip install -U dist/tir_framework-1.20.23rc2.tar.gz pause >nul | set/p = Press any key to exit ... From 12caa71f261a16b52cd11c0d76f9f2b2c849df74 Mon Sep 17 00:00:00 2001 From: 98llm Date: Mon, 19 Aug 2024 16:11:30 -0300 Subject: [PATCH 06/25] parameter_screen none return fix --- tir/technologies/webapp_internal.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tir/technologies/webapp_internal.py b/tir/technologies/webapp_internal.py index ccdabad5e..bef5ef566 100644 --- a/tir/technologies/webapp_internal.py +++ b/tir/technologies/webapp_internal.py @@ -8198,7 +8198,12 @@ def parameter_screen(self, restore_backup): container = self.get_current_container() if self.webapp_shadowroot(): - label_serv1 = next(iter(self.find_shadow_element('wa-tree-node', self.soup_to_selenium(container.select('wa-tree')[0])))) + bs_tree = container.select('wa-tree') + if bs_tree: + shadow_tree_node = self.find_shadow_element('wa-tree-node', + self.soup_to_selenium(next(iter(bs_tree)))) + if shadow_tree_node: + label_serv1 = next(iter(shadow_tree_node), None) else: img_serv1 = next(iter(container.select("img[src*='bmpserv1']")), None ) label_serv1 = next(iter(img_serv1.parent.select('label')), None) From 556e25f6f5c0f53e1e381fa022be406589849489 Mon Sep 17 00:00:00 2001 From: renanllisboa Date: Tue, 20 Aug 2024 16:46:17 -0300 Subject: [PATCH 07/25] protecting chrome_driver manager, adding some tryings. --- tir/technologies/core/base.py | 41 ++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/tir/technologies/core/base.py b/tir/technologies/core/base.py index 6dc71fdf2..81997aaca 100644 --- a/tir/technologies/core/base.py +++ b/tir/technologies/core/base.py @@ -1101,6 +1101,7 @@ def Start(self): """ start_program = '#inputStartProg, #selectStartProg' + driver_path = None if self.config.appserver_service: try: @@ -1127,21 +1128,31 @@ def Start(self): if self.config.headless: chrome_options.add_argument('force-device-scale-factor=0.77') - try: - if self.config.chromedriver_auto_install: - if self.config.ssl_chrome_auto_install_disable: - os.environ['WDM_SSL_VERIFY'] = '0' - self.driver = webdriver.Chrome(options=chrome_options, - executable_path=ChromeDriverManager().install()) - else: - if sys.platform == 'linux': - driver_path = Path(__file__).parent.resolve().joinpath('drivers', 'linux', 'chromedriver.exe') - elif sys.platform == 'win32': - driver_path = Path(__file__).parent.resolve().joinpath('drivers', 'windows', 'chromedriver.exe') - - self.driver = webdriver.Chrome(options=chrome_options, executable_path=str(driver_path)) - except Exception as e: - raise e + if self.config.chromedriver_auto_install: + + counter = 1 + while counter < 3: + try: + if self.config.ssl_chrome_auto_install_disable: + os.environ['WDM_SSL_VERIFY'] = '0' + driver_path = ChromeDriverManager().install() + break + except Exception as e: + logger().info("Trying get driver_path from ChromeDriverManager().Install") + time.sleep(30) + counter += 1 + if counter > 2: + raise e + + else: + if sys.platform == 'linux': + driver_path = Path(__file__).parent.resolve().joinpath('drivers', 'linux', + 'chromedriver.exe') + elif sys.platform == 'win32': + driver_path = Path(__file__).parent.resolve().joinpath('drivers', 'windows', + 'chromedriver.exe') + + self.driver = webdriver.Chrome(options=chrome_options, executable_path=str(driver_path)) elif self.config.browser.lower() == "electron": driver_path = os.path.join(os.path.dirname(__file__), r'drivers\\windows\\electron\\chromedriver.exe') From b13a47dacab372d537b5754a2aa61d0e67c95027 Mon Sep 17 00:00:00 2001 From: 98llm Date: Wed, 21 Aug 2024 09:18:22 -0300 Subject: [PATCH 08/25] hotfix chrome combobox triggers --- tir/technologies/webapp_internal.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tir/technologies/webapp_internal.py b/tir/technologies/webapp_internal.py index ccdabad5e..d1cd93bbf 100644 --- a/tir/technologies/webapp_internal.py +++ b/tir/technologies/webapp_internal.py @@ -2803,6 +2803,10 @@ def input_value(self, field, value, ignore_case=True, name_attr=False, position= self.select_combo(element, main_value, index=True) else: self.select_combo(element, main_value) + if self.config.browser.lower() == 'chrome': # TODO to monitor ATFA005 behavior + self.set_element_focus(input_field()) + ActionChains(self.driver).send_keys(Keys.ENTER).perform() + current_value = self.return_selected_combo_value(element).strip() #Action for Input elements else: From c6acef84e127615e8710f38107f03256b4b5d539 Mon Sep 17 00:00:00 2001 From: 98llm Date: Thu, 22 Aug 2024 09:06:26 -0300 Subject: [PATCH 09/25] hotfix grids combobox --- tir/technologies/webapp_internal.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tir/technologies/webapp_internal.py b/tir/technologies/webapp_internal.py index ccdabad5e..1b7dd04c2 100644 --- a/tir/technologies/webapp_internal.py +++ b/tir/technologies/webapp_internal.py @@ -6406,6 +6406,10 @@ def fill_grid(self, field, x3_dictionaries, initial_layer, duplicate_fields=[]): self.log_error("Couldn't find option") if (option_text != option_value_dict[option_value]): self.select_combo(new_container, field[1]) if self.webapp_shadowroot() else self.select_combo(child, field[1]) + + if self.config.browser.lower() == 'chrome': # TODO to monitor ATFA005 behavior + self.set_element_focus(self.soup_to_selenium(new_container)) + ActionChains(self.driver).send_keys(Keys.ENTER).perform() if field[1] in option_text[0:len(field[1])]: current_value = field[1] else: From c803ec4f2febdfbe45ca039af9c6ccd4e69dfd1f Mon Sep 17 00:00:00 2001 From: renanllisboa Date: Thu, 22 Aug 2024 14:57:09 -0300 Subject: [PATCH 10/25] change default release in checks_empty_line() method --- tir/technologies/core/log.py | 2 +- tir/technologies/core/logging_config.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tir/technologies/core/log.py b/tir/technologies/core/log.py index 44a5c6ed1..bde55d254 100644 --- a/tir/technologies/core/log.py +++ b/tir/technologies/core/log.py @@ -227,7 +227,7 @@ def checks_empty_line(self): self.table_rows[row][3] = 'NO PROGRAM' if self.table_rows[row][10] == '': - self.table_rows[row][10] = '12.1.2310' + self.table_rows[row][10] = '12.1.2410' if self.table_rows[row][15] == '': self.table_rows[row][15] = 'BRA' diff --git a/tir/technologies/core/logging_config.py b/tir/technologies/core/logging_config.py index 003d644a2..7c64eb692 100644 --- a/tir/technologies/core/logging_config.py +++ b/tir/technologies/core/logging_config.py @@ -158,4 +158,3 @@ def create_file(folder, filename): except Exception as error: time.sleep(30) logger().debug(str(error)) - From 67b9c8d5e6c5fe098a74d03a0b6c9232bab734aa Mon Sep 17 00:00:00 2001 From: renanllisboa Date: Tue, 27 Aug 2024 15:46:12 -0300 Subject: [PATCH 11/25] added try in escape to menu method --- tir/technologies/webapp_internal.py | 45 ++++++++++++----------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/tir/technologies/webapp_internal.py b/tir/technologies/webapp_internal.py index e98deb3b1..8c5666f65 100644 --- a/tir/technologies/webapp_internal.py +++ b/tir/technologies/webapp_internal.py @@ -1599,19 +1599,7 @@ def set_program(self, program): try: logger().info(f"Setting program: {program}") - if not self.webapp_shadowroot(): - ActionChains(self.driver).key_down(Keys.ESCAPE).perform() - elif self.check_layers('wa-dialog') > 1: - logger().debug('Escape to menu') - # self.log.take_screenshot_log(driver=self.driver, description='set_program', - # stack_item=self.log.get_testcase_stack()) # TODO trecho inserido para analise - ActionChains(self.driver).key_down(Keys.ESCAPE).perform() - - if self.check_layers('wa-dialog') > 1: - logger().debug('Found layers after Escape to menu') - # self.log.take_screenshot_log(driver=self.driver, description='set_program', - # stack_item=self.log.get_testcase_stack()) # TODO trecho inserido para analise - self.close_screen_before_menu() + self.escape_to_main_menu() self.wait_element(term=cget_term, scrap_type=enum.ScrapType.CSS_SELECTOR, main_container="body") @@ -1680,6 +1668,23 @@ def set_program(self, program): except Exception as e: logger().exception(str(e)) + def escape_to_main_menu(self): + """ + + """ + + endtime = time.time() + self.config.time_out + while time.time() < endtime and self.check_layers('wa-dialog') > 1: + if not self.webapp_shadowroot(): + ActionChains(self.driver).key_down(Keys.ESCAPE).perform() + elif self.check_layers('wa-dialog') > 1: + logger().info('Escape to menu') + ActionChains(self.driver).key_down(Keys.ESCAPE).perform() + + if self.check_layers('wa-dialog') > 1: + logger().info('Found layers after Escape to menu') + self.close_screen_before_menu() + def check_layers(self, term): """ [Internal] @@ -3945,19 +3950,7 @@ def SetLateralMenu(self, menu_itens, save_input=True, click_menu_functional=Fals endtime = time.time() + self.config.time_out menu_itens = list(map(str.strip, menu_itens.split(">"))) - if not self.webapp_shadowroot(): - ActionChains(self.driver).key_down(Keys.ESCAPE).perform() - elif self.check_layers('wa-dialog') > 1: - logger().debug('Escape to menu') - # self.log.take_screenshot_log(driver=self.driver, description='SetLateralMenu', - # stack_item=self.log.get_testcase_stack()) # TODO trecho inserido para analise - ActionChains(self.driver).key_down(Keys.ESCAPE).perform() - - if self.check_layers('wa-dialog') > 1: - logger().debug('Found layers after Escape to menu') - # self.log.take_screenshot_log(driver=self.driver, description='SetLateralMenu', - # stack_item=self.log.get_testcase_stack()) # TODO trecho inserido para analise - self.close_screen_before_menu() + self.escape_to_main_menu() self.wait_element(term=menu_term, scrap_type=enum.ScrapType.CSS_SELECTOR, main_container="body") From 4f9cf729139c2de455c3b28c7be53bd80085d0a1 Mon Sep 17 00:00:00 2001 From: renanllisboa Date: Tue, 27 Aug 2024 15:47:56 -0300 Subject: [PATCH 12/25] branch release v1.20.23rc3 --- scripts/install_package.cmd | 2 +- tir/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install_package.cmd b/scripts/install_package.cmd index a397ec1a2..e463aa593 100644 --- a/scripts/install_package.cmd +++ b/scripts/install_package.cmd @@ -13,5 +13,5 @@ taskkill /f /im chromedriver.exe echo ------------------------- echo Installing project... echo ------------------------- -pip install -U dist/tir_framework-1.20.23rc2.tar.gz +pip install -U dist/tir_framework-1.20.23rc3.tar.gz pause >nul | set/p = Press any key to exit ... diff --git a/tir/version.py b/tir/version.py index bbc7a7119..047746418 100644 --- a/tir/version.py +++ b/tir/version.py @@ -1 +1 @@ -__version__ = '1.20.23rc2' +__version__ = '1.20.23rc3' From fafca311af2698b77d35b0fabab0734883137403 Mon Sep 17 00:00:00 2001 From: 98llm Date: Tue, 27 Aug 2024 17:30:34 -0300 Subject: [PATCH 13/25] webapp change log method --- tir/technologies/core/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tir/technologies/core/base.py b/tir/technologies/core/base.py index 81997aaca..4753ac8fe 100644 --- a/tir/technologies/core/base.py +++ b/tir/technologies/core/base.py @@ -1308,7 +1308,7 @@ def webapp_shadowroot(self, shadow_root=True): try: current_ver = self.driver.execute_script("return app.VERSION") if current_ver: - logger().debug(f'Webapp: {current_ver}') + logger().info(f'Webapp: {current_ver}') current_ver = re.sub(r'\.(.*)', '', current_ver) self.webapp_version = int(current_ver) >= 8 return self.webapp_version From 0d310943ff2a7dc18d9156eb3df16854065cf2a3 Mon Sep 17 00:00:00 2001 From: 98llm Date: Wed, 28 Aug 2024 14:07:12 -0300 Subject: [PATCH 14/25] docstring setButton update --- tir/main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tir/main.py b/tir/main.py index 8ac8e5356..513ac52aa 100644 --- a/tir/main.py +++ b/tir/main.py @@ -597,6 +597,13 @@ def SetButton(self, button, sub_item="", position=1, check_error=True): :param position: Position which element is located. - **Default:** 1 :type position: int + > ⚠️ **Warning:** + > If there are a sequence of similar buttons. Example: + `self.oHelper.SetButton("Salvar")` + `self.oHelper.SetButton("Salvar")` + We recomend insert some wait of elements method between them, like WaitShow, WaitHide... etc. + This way you ensure the correct element be selected in correct screen. + Usage: >>> # Calling the method to click on a regular button: From d8863224de4dd7eb9fbe7a7b65e47dd7cde96b89 Mon Sep 17 00:00:00 2001 From: 98llm Date: Wed, 28 Aug 2024 14:07:56 -0300 Subject: [PATCH 15/25] update setButton docstrings --- tir/technologies/webapp_internal.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tir/technologies/webapp_internal.py b/tir/technologies/webapp_internal.py index 8c5666f65..92274abbe 100644 --- a/tir/technologies/webapp_internal.py +++ b/tir/technologies/webapp_internal.py @@ -4187,6 +4187,13 @@ def SetButton(self, button, sub_item="", position=1, check_error=True): :param position: Position which element is located. - **Default:** 1 :type position: int + > ⚠️ **Warning:** + > If there are a sequence of similar buttons. Example: + `self.oHelper.SetButton("Salvar")` + `self.oHelper.SetButton("Salvar")` + We recomend insert some wait of elements method between them, like WaitShow, WaitHide... etc. + This way you ensure the correct element be selected in correct screen. + Usage: >>> # Calling the method to click on a regular button: From b9e2a04feaf7e00cb0e47912836054a51c842cc6 Mon Sep 17 00:00:00 2001 From: renanllisboa Date: Wed, 28 Aug 2024 15:57:08 -0300 Subject: [PATCH 16/25] Adding default value to the group field if doesn't exist. --- tir/technologies/webapp_internal.py | 59 +++++++++++++++++------------ 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/tir/technologies/webapp_internal.py b/tir/technologies/webapp_internal.py index e98deb3b1..2a97d237b 100644 --- a/tir/technologies/webapp_internal.py +++ b/tir/technologies/webapp_internal.py @@ -883,30 +883,7 @@ def filling_group(self, shadow_root=None, container=None): endtime = time.time() + self.config.time_out / 2 while (time.time() < endtime and (group_value.strip() != self.config.group.strip())): - if self.config.poui_login: - group_elements = self.web_scrap(term=self.language.group, main_container='body', - scrap_type=enum.ScrapType.TEXT, twebview=True) - - if group_elements: - group_element = next(iter(group_elements)) - group_element = group_element.find_parent('pro-company-lookup') - group_element = next(iter(group_element.select('input')), None) - else: - if self.webapp_shadowroot(shadow_root=shadow_root): - group_elements = self.web_scrap(term="[name='cGroup'], [name='__cGroup']", - scrap_type=enum.ScrapType.CSS_SELECTOR, - main_container='body', - optional_term='wa-text-input') - else: - group_elements = self.web_scrap(term="[name='cGroup'] input, [name='__cGroup'] input", - scrap_type=enum.ScrapType.CSS_SELECTOR, label=True, - main_container=container) - - if group_elements: - if len(group_elements) > 1: - group_element = group_elements.pop() - else: - group_element = next(iter(group_elements), None) + group_element = self.group_element(shadow_root, container) if group_element: group = lambda: self.soup_to_selenium(group_element) @@ -930,6 +907,40 @@ def filling_group(self, shadow_root=None, container=None): if click_type > 3: click_type = 1 + if not self.config.group: + group_content = self.get_web_value(self.soup_to_selenium(self.group_element(shadow_root, container))) + if group_content: + self.config.group = group_content + else: + self.log_error(f'Please, fill group parameter in Setup() method') + + def group_element(self, shadow_root, container): + + if self.config.poui_login: + group_elements = self.web_scrap(term=self.language.group, main_container='body', + scrap_type=enum.ScrapType.TEXT, twebview=True) + + if group_elements: + group_element = next(iter(group_elements)) + group_element = group_element.find_parent('pro-company-lookup') + return next(iter(group_element.select('input')), None) + else: + if self.webapp_shadowroot(shadow_root=shadow_root): + group_elements = self.web_scrap(term="[name='cGroup'], [name='__cGroup']", + scrap_type=enum.ScrapType.CSS_SELECTOR, + main_container='body', + optional_term='wa-text-input') + else: + group_elements = self.web_scrap(term="[name='cGroup'] input, [name='__cGroup'] input", + scrap_type=enum.ScrapType.CSS_SELECTOR, label=True, + main_container=container) + + if group_elements: + if len(group_elements) > 1: + return group_elements.pop() + else: + return next(iter(group_elements), None) + def filling_branch(self, shadow_root=None, container=None): """ [Internal] From 23ca9cc3d92f9b7613a0a284fd3cd97b76df43e5 Mon Sep 17 00:00:00 2001 From: 98llm Date: Wed, 28 Aug 2024 16:25:06 -0300 Subject: [PATCH 17/25] Schedule method --- tir/main.py | 6 +++ tir/technologies/core/language.py | 15 +++++-- tir/technologies/webapp_internal.py | 62 ++++++++++++++++++++++++++++- 3 files changed, 78 insertions(+), 5 deletions(-) diff --git a/tir/main.py b/tir/main.py index 8ac8e5356..edb64a041 100644 --- a/tir/main.py +++ b/tir/main.py @@ -1488,6 +1488,12 @@ def CurrentWorkDirectory(self): return os.chmod() + def StartSchedule(self): + """Access de Schedule settings and Start all itens + + """ + return self.__webapp.set_schedule(schedule_status=True) + class Apw(): def __init__(self, config_path=""): diff --git a/tir/technologies/core/language.py b/tir/technologies/core/language.py index 48a485ee9..823c37658 100644 --- a/tir/technologies/core/language.py +++ b/tir/technologies/core/language.py @@ -87,6 +87,7 @@ def __init__(self, language="pt-BR"): self.success = languagepack["Success"] self.procedure_install = languagepack["Procedure Install"] self.procedure_uninstall = languagepack["Procedure Uninstall"] + self.schedule_menu = languagepack["Schedule Menu"] self.messages = Messages(languagepack) @@ -182,7 +183,8 @@ def get_language_pack(self, language): "Code": "Code", "Success": "Success", "Procedure Install": "Install selected processes", - "Procedure Uninstall": "Remove selected processes" + "Procedure Uninstall": "Remove selected processes", + "Schedule Menu": "Ambiente > Schedule > Schedule" } @@ -276,7 +278,9 @@ def get_language_pack(self, language): "Code": "Código", "Success": "Sucessos", "Procedure Install": "Instalar processos selecionados", - "Procedure Uninstall": "Remover processos selecionados" + "Procedure Uninstall": "Remover processos selecionados", + "Schedule Menu": "Ambiente > Schedule > Schedule" + } spanish = { "User": "Usuário", @@ -368,7 +372,9 @@ def get_language_pack(self, language): "Code": "Código", "Success": "Sucessos", "Procedure Install": "Instalar processos selecionados", - "Procedure Uninstall": "Remover processos selecionados" + "Procedure Uninstall": "Remover processos selecionados", + "Schedule Menu": "Ambiente > Schedule > Schedule" + } russian = { "User": "Пользователь", @@ -462,7 +468,8 @@ def get_language_pack(self, language): "Code": "Код", "Success": "успех", "Procedure Install": "Установить выбранные процессы", - "Procedure Uninstall": "Удалить выбранные процессы" + "Procedure Uninstall": "Удалить выбранные процессы", + "Schedule Menu": "Ambiente > Schedule > Schedule" } if language.lower() == "en-us": diff --git a/tir/technologies/webapp_internal.py b/tir/technologies/webapp_internal.py index 8c5666f65..b969a0a69 100644 --- a/tir/technologies/webapp_internal.py +++ b/tir/technologies/webapp_internal.py @@ -10892,4 +10892,64 @@ def check_release_newlog(self): return self.log.release and self.config.new_log def log_error_newlog(self): - self.log_error('Please check config.json key "Release".It is necessary to generate the log on the dashboard. ex: "Release": "12.1.2310" ') \ No newline at end of file + self.log_error('Please check config.json key "Release".It is necessary to generate the log on the dashboard. ex: "Release": "12.1.2310" ') + + + def set_schedule(self, schedule_status): + """Access de Schedule settings and Start run all itens + + """ + + exception = None + service_status = False + self.tmenu_screen = self.check_tmenu_screen() + + try: + self.driver_refresh() + except Exception as error: + exception = error + + if not exception: + if self.config.browser.lower() == "chrome": + try: + self.wait_until_to( expected_condition = "alert_is_present" ) + self.driver.switch_to_alert().accept() + except: + pass + + #Access Schedule environment + self.Setup("SIGACFG", self.config.date, self.config.group, self.config.branch, save_input=False) + self.SetLateralMenu(self.language.schedule_menu, save_input=False) + + #Wait show grid + self.wait_element_timeout(term=self.grid_selectors["new_web_app"], scrap_type=enum.ScrapType.CSS_SELECTOR, + timeout= self.config.time_out/2, + main_container='body') + + endtime = time.time() + self.config.time_out/2 + while time.time() < endtime and not service_status: + grid_rows = self.get_grid_content(0, self.grid_selectors["new_web_app"]) + if grid_rows: + stoped_itens = list(filter(lambda x: 'Parado' in x.text, grid_rows)) + if stoped_itens and schedule_status: + self.ClickIcon('Iniciar Todos Serviços') + started_itens = list(filter(lambda x: 'Iniciado' in x.text, grid_rows)) + self.ClickIcon('Atualizar') + if started_itens: + service_status = True + + logger().info(f"Finish Schedule Start") + if not service_status: + self.log_error("Schedule culdn't start") + + self.driver.get(self.config.url) + self.Setup(self.config.initial_program, self.config.date, self.config.group, + self.config.branch, save_input=not self.config.autostart) + + if not self.tmenu_screen: + if ">" in self.config.routine: + self.SetLateralMenu(self.config.routine, save_input=False) + else: + self.Program(self.config.routine) + + self.tmenu_screen = None \ No newline at end of file From 3d043dabbcd38ab1bbca6a825da31bc3ed453622 Mon Sep 17 00:00:00 2001 From: 98llm Date: Wed, 28 Aug 2024 17:24:18 -0300 Subject: [PATCH 18/25] SetSchedule --- tir/main.py | 6 ++++++ tir/technologies/webapp_internal.py | 14 ++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tir/main.py b/tir/main.py index edb64a041..deff3acf3 100644 --- a/tir/main.py +++ b/tir/main.py @@ -1494,6 +1494,12 @@ def StartSchedule(self): """ return self.__webapp.set_schedule(schedule_status=True) + def StopSchedule(self): + """Access de Schedule settings and Start all itens + + """ + return self.__webapp.set_schedule(schedule_status=False) + class Apw(): def __init__(self, config_path=""): diff --git a/tir/technologies/webapp_internal.py b/tir/technologies/webapp_internal.py index b969a0a69..3f959cb5a 100644 --- a/tir/technologies/webapp_internal.py +++ b/tir/technologies/webapp_internal.py @@ -10902,6 +10902,8 @@ def set_schedule(self, schedule_status): exception = None service_status = False + schedule_run = 'Iniciar Todos Serviços' if schedule_status else 'Parar Todos Serviços' + service_curr_status = 'Iniciado' if schedule_status else 'Parado' self.tmenu_screen = self.check_tmenu_screen() try: @@ -10930,15 +10932,15 @@ def set_schedule(self, schedule_status): while time.time() < endtime and not service_status: grid_rows = self.get_grid_content(0, self.grid_selectors["new_web_app"]) if grid_rows: - stoped_itens = list(filter(lambda x: 'Parado' in x.text, grid_rows)) - if stoped_itens and schedule_status: - self.ClickIcon('Iniciar Todos Serviços') - started_itens = list(filter(lambda x: 'Iniciado' in x.text, grid_rows)) + stoped_itens = list(filter(lambda x: not service_curr_status in x.text, grid_rows)) + if stoped_itens: + self.ClickIcon(schedule_run) self.ClickIcon('Atualizar') - if started_itens: + service_changed = list(filter(lambda x: service_curr_status in x.text, grid_rows)) + if service_changed: service_status = True - logger().info(f"Finish Schedule Start") + logger().info(f"Schedule: {service_curr_status}") if not service_status: self.log_error("Schedule culdn't start") From 350017b765620ef165148adffb5079faff3b49c7 Mon Sep 17 00:00:00 2001 From: 98llm Date: Wed, 28 Aug 2024 17:26:58 -0300 Subject: [PATCH 19/25] docstrings update --- tir/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tir/main.py b/tir/main.py index deff3acf3..5297b8b97 100644 --- a/tir/main.py +++ b/tir/main.py @@ -1495,7 +1495,7 @@ def StartSchedule(self): return self.__webapp.set_schedule(schedule_status=True) def StopSchedule(self): - """Access de Schedule settings and Start all itens + """Access de Schedule settings and Stop all itens """ return self.__webapp.set_schedule(schedule_status=False) From 1e7d3e3c8d0bf4f4db30d3424a680f76796e389e Mon Sep 17 00:00:00 2001 From: 98llm Date: Wed, 28 Aug 2024 17:31:28 -0300 Subject: [PATCH 20/25] language update --- tir/technologies/core/language.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tir/technologies/core/language.py b/tir/technologies/core/language.py index 823c37658..16c82d587 100644 --- a/tir/technologies/core/language.py +++ b/tir/technologies/core/language.py @@ -184,7 +184,7 @@ def get_language_pack(self, language): "Success": "Success", "Procedure Install": "Install selected processes", "Procedure Uninstall": "Remove selected processes", - "Schedule Menu": "Ambiente > Schedule > Schedule" + "Schedule Menu": "Settings > Schedule > Schedule" } @@ -373,7 +373,7 @@ def get_language_pack(self, language): "Success": "Sucessos", "Procedure Install": "Instalar processos selecionados", "Procedure Uninstall": "Remover processos selecionados", - "Schedule Menu": "Ambiente > Schedule > Schedule" + "Schedule Menu": "Entorno > Schedule > Schedule" } russian = { @@ -469,7 +469,7 @@ def get_language_pack(self, language): "Success": "успех", "Procedure Install": "Установить выбранные процессы", "Procedure Uninstall": "Удалить выбранные процессы", - "Schedule Menu": "Ambiente > Schedule > Schedule" + "Schedule Menu": "Settings > Schedule > Schedule" } if language.lower() == "en-us": From a1105f66c0b1edfc4752eacb88d8d9f8a29c2b5f Mon Sep 17 00:00:00 2001 From: 98llm Date: Mon, 2 Sep 2024 10:58:45 -0300 Subject: [PATCH 21/25] validate clickcheckbox input --- tir/technologies/webapp_internal.py | 60 +++++++++++++++++++---------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/tir/technologies/webapp_internal.py b/tir/technologies/webapp_internal.py index 8c5666f65..b4eba5df0 100644 --- a/tir/technologies/webapp_internal.py +++ b/tir/technologies/webapp_internal.py @@ -8530,35 +8530,26 @@ def ClickCheckBox(self, label_box_name, position=1, double_click=False): endtime = time.time() + self.config.time_out while time.time() < endtime and not success: - - container = self.get_current_container() - if not container: - self.log_error("Couldn't locate container.") - - labels_boxs = container.select("span, wa-checkbox") - label_box_name = label_box_name.lower().strip() - if self.webapp_shadowroot(): - filtered_labels_boxs = list(filter(lambda x: label_box_name in x.get('caption').lower().strip(), labels_boxs)) - else: - filtered_labels_boxs = list(filter(lambda x: label_box_name in x.text.lower().strip(), labels_boxs)) - if not filtered_labels_boxs: - filtered_labels_boxs = list(filter(lambda x: label_box_name.lower() in x.parent.text.lower(), labels_boxs)) - if position <= len(filtered_labels_boxs): - position -= 1 - label_box = filtered_labels_boxs[position].parent if not self.webapp_shadowroot() else filtered_labels_boxs[position] - + label_box = self.get_checkbox_label(label_box_name, position) + if label_box: + checked_status =lambda: (hasattr(self.get_checkbox_label(label_box_name, position), 'attrs') and + 'checked' in self.get_checkbox_label(label_box_name, position).attrs) if 'tcheckbox' or 'dict-tcheckbox' in label_box.get_attribute_list('class'): - label_box_element = lambda: self.soup_to_selenium(label_box) + label_box_element = lambda: self.soup_to_selenium(label_box) + check_before_click = checked_status() + if self.webapp_shadowroot(): label_box_element = lambda: next(iter(self.find_shadow_element('input', self.soup_to_selenium(label_box))), None) if double_click: success = self.send_action(action=self.double_click, element=label_box_element) else: - success = self.send_action(action=self.click, element=label_box_element) + self.send_action(action=self.click, element=label_box_element) + check_after_click = checked_status() + success = check_after_click != check_before_click if not success: - label_box = filtered_labels_boxs[position].parent + label_box = label_box.parent if label_box.find_next('img'): if hasattr(label_box.find_next('img'), 'src'): img = label_box.find_next('img').attrs['src'].split('/')[-1] if \ @@ -8576,6 +8567,35 @@ def ClickCheckBox(self, label_box_name, position=1, double_click=False): if not success: self.log_error("Checkbox index is invalid.") + def get_checkbox_label(self, label_box_name, position): + '''Get checkbox from label name + + :param label_box_name: String + :param position: int + :return: BS object + ''' + label_box = None + container = self.get_current_container() + if not container: + self.log_error("Couldn't locate container.") + + labels_boxs = container.select("span, wa-checkbox") + label_box_name = label_box_name.lower().strip() + if self.webapp_shadowroot(): + filtered_labels_boxs = list( + filter(lambda x: label_box_name in x.get('caption').lower().strip(), labels_boxs)) + else: + filtered_labels_boxs = list(filter(lambda x: label_box_name in x.text.lower().strip(), labels_boxs)) + if not filtered_labels_boxs: + filtered_labels_boxs = list(filter(lambda x: label_box_name.lower() in x.parent.text.lower(), labels_boxs)) + + if position <= len(filtered_labels_boxs): + position -= 1 + label_box = filtered_labels_boxs[position].parent if not self.webapp_shadowroot() else filtered_labels_boxs[ + position] + + return label_box + def ClickLabel(self, label_name, position=0): """ Clicks on a Label on the screen. From 462727876f9df9055a9191a5d2338bfdfbe8e97c Mon Sep 17 00:00:00 2001 From: renanllisboa Date: Wed, 4 Sep 2024 14:45:45 -0300 Subject: [PATCH 22/25] add get_program_name method in log.py to fill program info in log. --- tir/technologies/core/log.py | 38 +++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/tir/technologies/core/log.py b/tir/technologies/core/log.py index bde55d254..4a3377d7f 100644 --- a/tir/technologies/core/log.py +++ b/tir/technologies/core/log.py @@ -224,13 +224,13 @@ def checks_empty_line(self): for row in range(0, len(self.table_rows)): if self.table_rows[row][3] == '': - self.table_rows[row][3] = 'NO PROGRAM' + self.table_rows[row][3] = self.get_program_name() if self.table_rows[row][10] == '': - self.table_rows[row][10] = '12.1.2410' + self.table_rows[row][10] = self.config.release if self.config.release else '12.1.2410' if self.table_rows[row][15] == '': - self.table_rows[row][15] = 'BRA' + self.table_rows[row][15] = self.config.country if self.config.country else 'BRA' if self.table_rows[row][7] == 1: if self.table_rows[row][11] == '': @@ -553,3 +553,35 @@ def search_stack(self, function): >>> is_present = self.search_stack("MATA020") """ return len(list(filter(lambda x: x.function == function, inspect.stack()))) > 0 + + def get_program_name(self): + """ + [Internal] + """ + stack_item_splited = next(iter(map(lambda x: x.filename.split(self.replace_slash("\\")), filter( + lambda x: "TESTSUITE.PY" in x.filename.upper() or "TESTCASE.PY" in x.filename.upper(), inspect.stack()))), + None) + + if stack_item_splited: + get_file_name = next(iter(list( + map(lambda x: "TESTSUITE.PY" if "TESTSUITE.PY" in x.upper() else "TESTCASE.PY", stack_item_splited)))) + + if get_file_name: + program_name = next(iter(list(map(lambda x: re.findall(fr"(\w+)(?:{get_file_name})", x.upper()), + filter(lambda x: ".PY" in x.upper(), stack_item_splited)))), None) + + if program_name: + return next(iter(program_name)) + else: + return None + else: + return None + + def replace_slash(self, path): + + slash = r"/" if (sys.platform.lower() == "linux") else r"\\" + + pattern = re.compile(r'[\/\\]') + + if pattern.findall(path): + return pattern.sub(slash, path) From dd1f513b1d6bd6fe6d1051d10fbdb07724fe3f54 Mon Sep 17 00:00:00 2001 From: renanllisboa Date: Wed, 4 Sep 2024 14:50:24 -0300 Subject: [PATCH 23/25] Branch release v1.20.23rc4 --- scripts/install_package.cmd | 2 +- tir/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install_package.cmd b/scripts/install_package.cmd index e463aa593..e1a6fb69d 100644 --- a/scripts/install_package.cmd +++ b/scripts/install_package.cmd @@ -13,5 +13,5 @@ taskkill /f /im chromedriver.exe echo ------------------------- echo Installing project... echo ------------------------- -pip install -U dist/tir_framework-1.20.23rc3.tar.gz +pip install -U dist/tir_framework-1.20.23rc4.tar.gz pause >nul | set/p = Press any key to exit ... diff --git a/tir/version.py b/tir/version.py index 047746418..900925057 100644 --- a/tir/version.py +++ b/tir/version.py @@ -1 +1 @@ -__version__ = '1.20.23rc3' +__version__ = '1.20.23rc4' From 917f8ddde137d94ac8bbf9cc2bb8b8f659303224 Mon Sep 17 00:00:00 2001 From: LEANDRO L MONTEIRO <60761500+98llm@users.noreply.github.com> Date: Fri, 6 Sep 2024 10:43:46 -0300 Subject: [PATCH 24/25] Update version.py --- tir/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tir/version.py b/tir/version.py index 900925057..3c823286e 100644 --- a/tir/version.py +++ b/tir/version.py @@ -1 +1 @@ -__version__ = '1.20.23rc4' +__version__ = '1.20.23' From 67aec98ba1d036ef196f5e1483ad33745cfe82e9 Mon Sep 17 00:00:00 2001 From: LEANDRO L MONTEIRO <60761500+98llm@users.noreply.github.com> Date: Fri, 6 Sep 2024 10:44:05 -0300 Subject: [PATCH 25/25] Update install_package.cmd --- scripts/install_package.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install_package.cmd b/scripts/install_package.cmd index e1a6fb69d..e84db50c1 100644 --- a/scripts/install_package.cmd +++ b/scripts/install_package.cmd @@ -13,5 +13,5 @@ taskkill /f /im chromedriver.exe echo ------------------------- echo Installing project... echo ------------------------- -pip install -U dist/tir_framework-1.20.23rc4.tar.gz +pip install -U dist/tir_framework-1.20.23.tar.gz pause >nul | set/p = Press any key to exit ...