Skip to content

Commit

Permalink
Merge pull request #1462 from totvs/release/v1.20.21
Browse files Browse the repository at this point in the history
Release/v1.20.21
  • Loading branch information
renanllisboa authored Jul 29, 2024
2 parents 91b5110 + 937ff5e commit 7112f23
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7
FROM python:3.7.9

ENV DEBIAN_FRONTEND=noninteractive

Expand Down
2 changes: 1 addition & 1 deletion scripts/install_package.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ taskkill /f /im chromedriver.exe
echo -------------------------
echo Installing project...
echo -------------------------
pip install -U dist/tir_framework-1.20.20.tar.gz
pip install -U dist/tir_framework-1.20.21.tar.gz
pause >nul | set/p = Press any key to exit ...
4 changes: 4 additions & 0 deletions tir/technologies/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,10 @@ def get_url(self, url=None):
num_of_trying = 1
while not get_url and num_of_trying <= 5:
self.driver.get(url)

if self.config.skip_environment:
return

try:
if self.config.json_data['POUILogin'] and 'StartProg' in url:
time.sleep(3)
Expand Down
4 changes: 3 additions & 1 deletion tir/technologies/core/base_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def disconnect_database(self, connection):
logger().info('DataBase connection already stopped')

def check_pyodbc_drivers(self, driver_database):
if not next(iter(list(filter(lambda x: x == driver_database, pyodbc.drivers()))), None):
if not next(iter(list(
filter(lambda x: x == driver_database.lower(), list(map(lambda x: x.lower(), pyodbc.drivers()))))),
None):
error_message = f"Driver: '{driver_database}' isn't a valid driver name!"
self.webapp_internal.restart_counter = 3
self.webapp_internal.log_error(error_message)
Expand Down
69 changes: 50 additions & 19 deletions tir/technologies/webapp_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ def user_screen(self, admin_user=False):
try_counter = 0
password_value = ''
endtime = time.time() + self.config.time_out
while (time.time() < endtime and not password_value.strip() and self.config.password != ''):
while (time.time() < endtime and not password_value and self.config.password != ''):

if self.config.poui_login:
soup = self.get_current_DOM(twebview=True)
Expand Down Expand Up @@ -648,7 +648,7 @@ def user_screen(self, admin_user=False):
self.wait_blocker()
try_counter += 1 if (try_counter < 1) else -1

if not password_value.strip() and self.config.password != '':
if not password_value and self.config.password != '':
self.restart_counter += 1
message = "Couldn't fill User input element."
self.log_error(message)
Expand Down Expand Up @@ -1568,6 +1568,13 @@ def Program(self, program_name):
self.routine = 'Program'
self.config.routine = program_name

if self.config.log_info_config:
self.set_log_info_config()

if self.config.new_log:
if not self.log.release:
self.log_error_newlog()

if not self.log.program:
self.log.program = program_name
self.set_program(program_name)
Expand Down Expand Up @@ -3130,6 +3137,7 @@ def GetValue(self, field, grid=False, line=1, grid_number=1, grid_memo_field=Fal
"""
endtime = time.time() + self.config.time_out
element = None
x3_dictionaries = None

if grid_memo_field:
self.grid_memo_field = True
Expand Down Expand Up @@ -3594,8 +3602,11 @@ def selenium_web_scrap(self, term, container, optional_term, second_term=None):
if container.select('.dict-tfolder') and self.search_navigation_bar(container.select('.dict-tfolder')):
labels_displayed = labels_not_none
if labels_displayed:
element = next(iter(list(filter(lambda x: term.lower() in x.text.lower().replace('\n', ''), labels_displayed))),
None)
element = list(filter(lambda x: term.lower() in x.text.lower().replace('\n', ''), labels_displayed))
if len(element) > 1:
element = next(iter(list(filter(lambda x: term.lower().strip() == x.text.lower().replace('\n', ''), element))),None)
else:
element = next(iter(element), None)
if not element:
element = next(iter(list(filter(lambda x: term.lower() in x.get_attribute('textContent').lower().replace('\n', '').replace('\t', ''), labels_displayed))),
None)
Expand Down Expand Up @@ -3901,6 +3912,13 @@ def SetLateralMenu(self, menu_itens, save_input=True, click_menu_functional=Fals
wait_screen = True if menu_itens != self.language.menu_about else False
used_ids = []

if self.config.log_info_config:
self.set_log_info_config()

if self.config.new_log:
if not self.check_release_newlog() and wait_screen:
self.log_error_newlog()

if save_input:
self.routine = 'SetLateralMenu'
self.config.routine = menu_itens
Expand Down Expand Up @@ -4239,9 +4257,10 @@ def SetButton(self, button, sub_item="", position=1, check_error=True):

if self.webapp_shadowroot():
if not soup_objects:
script = "return arguments[0].shadowRoot.querySelector('footer').querySelectorAll('wa-button')"
buttons = self.driver.execute_script(script, self.soup_to_selenium(soup))
filtered_button = list(filter(lambda x: x.text.strip().replace('\n', '') == button.strip().replace(' \n ', ''), buttons))
footer = self.find_shadow_element('footer', self.soup_to_selenium(soup), get_all=False)
buttons = self.find_shadow_element("wa-button", footer)
if buttons:
filtered_button = list(filter(lambda x: x.text.strip().replace('\n', '') == button.strip().replace(' \n ', ''), buttons))

if filtered_button and len(filtered_button) - 1 >= position:
parents_actives = list(filter(lambda x: self.filter_active_tabs(x), filtered_button ))
Expand Down Expand Up @@ -4422,7 +4441,7 @@ def SetButton(self, button, sub_item="", position=1, check_error=True):
def set_button_x(self, position=1, check_error=True):
endtime = self.config.time_out/2
if self.webapp_shadowroot():
term_button = f"wa-dialog[title*={self.language.warning}], wa-button[icon*='fwskin_delete_ico'], wa-image[src*='fwskin_modal_close.png'], wa-dialog"
term_button = f"wa-dialog[title*={self.language.warning}], wa-button[icon*='fwskin_delete_ico'], wa-button[style*='fwskin_delete_ico'], wa-image[src*='fwskin_modal_close.png'], wa-dialog"
else:
term_button = ".ui-button.ui-dialog-titlebar-close[title='Close'], img[src*='fwskin_delete_ico.png'], img[src*='fwskin_modal_close.png']"

Expand Down Expand Up @@ -4451,9 +4470,10 @@ def set_button_x(self, position=1, check_error=True):
element_soup = close_list.pop(position)
element_selenium = self.soup_to_selenium(element_soup)
if self.webapp_shadowroot():
if element_selenium.get_attribute('title') == self.language.warning or ('fundodlg_mdi.png' in element_selenium.value_of_css_property('--wa-dialog-background-image') and element_selenium.tag_name == 'wa-dialog') :
script = "return arguments[0].shadowRoot.querySelector('wa-dialog-header').shadowRoot.querySelector('button')"
element_selenium = self.driver.execute_script(script, element_selenium)
header = self.find_shadow_element('wa-dialog-header', element_selenium, get_all=False)
x_button = self.find_shadow_element("button[class~=button-close]", header, get_all=False)
if x_button:
element_selenium = x_button

self.scroll_to_element(element_selenium)
self.wait_until_to(expected_condition="element_to_be_clickable", element=element_soup, locator=By.XPATH)
Expand Down Expand Up @@ -7510,7 +7530,6 @@ def get_selected_row(self, rows):
filtered_rows = list(filter(lambda x: "selected-row" == self.soup_to_selenium(x).get_attribute('class'), rows))
if filtered_rows:
return next(iter(list(filter(lambda x: "selected-row" == self.soup_to_selenium(x).get_attribute('class'), rows))), None)
return next(reversed(rows), None)


def SetFilePath(self, value, button = ""):
Expand Down Expand Up @@ -7540,9 +7559,10 @@ def SetFilePath(self, value, button = ""):
self.driver.execute_script("document.querySelector('wa-file-picker').shadowRoot.querySelector('#{}').value='';".format(element.get_attribute("id")))

self.send_keys(element, self.replace_slash(value))
elements = self.driver.execute_script(f"return arguments[0].shadowRoot.querySelectorAll('button')", self.soup_to_selenium(containers_soup))
elements = self.find_shadow_element('button, wa-button', self.soup_to_selenium(containers_soup))
possible_buttons = button.upper() + '_' + self.language.open.upper() + '_' + self.language.save.upper()
elements = list(filter(lambda x: x.text.strip().upper() in possible_buttons, elements ))
if elements:
elements = list(filter(lambda x: x.text.strip().upper() in possible_buttons, elements))
else:
self.wait_element(self.language.file_name)
element = self.driver.find_element(By.CSS_SELECTOR, ".filepath input")
Expand Down Expand Up @@ -7899,7 +7919,7 @@ def log_error(self, message, new_log_line=True, skip_restart=False):
if stack_item != "setUpClass":
self.restart_counter = 0

if proceed_action():
if proceed_action() or not self.check_release_newlog():
if self.restart_counter >= 3:
self.restart_counter = 0
self.assertTrue(False, log_message)
Expand Down Expand Up @@ -9233,6 +9253,9 @@ def TearDown(self):
if self.config.smart_test:
self.log.log_exec_file()

if self.config.log_info_config:
self.set_log_info_config()

webdriver_exception = None
timeout = 1500
string = self.language.codecoverage #"Aguarde... Coletando informacoes de cobertura de codigo."
Expand Down Expand Up @@ -10499,11 +10522,14 @@ def find_child_element(self, term, element):
raise ValueError(message)


def find_shadow_element(self, term, objects):
def find_shadow_element(self, term, objects, get_all=True):

elements = None
if get_all:
script = f"return arguments[0].shadowRoot.querySelectorAll('{term}')"
else:
script = f"return arguments[0].shadowRoot.querySelector('{term}')"

script = f"return arguments[0].shadowRoot.querySelectorAll('{term}')"
try:
elements = self.driver.execute_script(script, objects)
except:
Expand Down Expand Up @@ -10837,7 +10863,6 @@ def SetCalendar(self, day='', month='', year='', position=0):
month = int(month) - 1
month_header = next(iter(self.find_shadow_element('wa-datepicker-month', elem_calendar)))
month_select = next(iter(self.find_shadow_element('select', month_header)))
month_interface = lambda: self.return_selected_combo_value(month_select, locator=True)
month_combo = self.return_combo_object(month_select, locator=True)
month_combo.select_by_index(str(month))
else:
Expand All @@ -10854,4 +10879,10 @@ def SetCalendar(self, day='', month='', year='', position=0):
while not day_selected() and time.time() < click_try:
self.click(filtered_day)
if filtered_day and month_combo and year_interface():
success = filtered_day.get_attribute('day') == day and month_combo.options.index(month_combo.first_selected_option) == month and year_interface() == year
success = filtered_day.get_attribute('day') == day and month_combo.options.index(month_combo.first_selected_option) == month and year_interface() == year

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" ')
2 changes: 1 addition & 1 deletion tir/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.20.20'
__version__ = '1.20.21'

0 comments on commit 7112f23

Please sign in to comment.