Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge 1.20.29rc4 to 2.0 #1627

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tir/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ def ProgramScreen(self, initial_program=""):
>>> # Calling the method:
>>> self.oHelper.ProgramScreen("SIGAADV")
"""
self.__webapp.program_screen(initial_program, coverage=self.coverage)
self.__webapp.program_screen(initial_program)

def OpenCSV(self, csv_file='', delimiter=';', column=None, header=None, filter_column=None, filter_value=''):
"""
Expand Down
29 changes: 23 additions & 6 deletions tir/technologies/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,18 +547,36 @@ def switch_to_iframe(self):

if not self.config.poui:
iframes = None
iframe_displayed = None
filtered_iframe = None
endtime = time.time() + self.config.time_out
while time.time() < endtime and not iframes:
iframes = self.driver.find_elements(By.CSS_SELECTOR, '[class*="twebview"], [class*="dict-twebengine"]')

if iframes:
iframe_displayed = next(iter(list(filter(lambda x: x.is_displayed(), iframes))), None)
filtered_iframe = self.filter_active_iframe(iframes)
else:
self.driver.switch_to.default_content()

if iframe_displayed:
self.driver.switch_to.frame(self.find_shadow_element('iframe', iframe_displayed)[0]) if self.webapp_shadowroot() else self.driver.switch_to.frame(iframe_displayed)
if filtered_iframe:
self.driver.switch_to.frame(self.find_shadow_element('iframe', filtered_iframe)[0]) if self.webapp_shadowroot() else self.driver.switch_to.frame(filtered_iframe)


def filter_active_iframe(self, iframes):
'''

:param iframes:
:type List
:return:
'''
iframes_displayed = []

iframes_displayed = list(filter(lambda x: x.is_displayed(), iframes))
iframes_filtred_zindex = list(filter(lambda x: x.get_attribute('style').split("z-index:")[1].split(";")[0].strip(), iframes_displayed))
if iframes_displayed and len(iframes_filtred_zindex) == len(iframes_displayed):
return max(iframes_filtred_zindex, key=lambda x: int(x.get_attribute('style').split("z-index:")[1].split(";")[0].strip()))
if not iframes_displayed:
return None


def get_element_text(self, element):
"""
Expand Down Expand Up @@ -757,7 +775,7 @@ def scroll_into_view(self, element):
except Exception as e:
logger().debug(f"********Warining scroll_to_element exception: {str(e)}*********")
pass

def search_zindex(self,element):
"""
[Internal]
Expand Down Expand Up @@ -884,7 +902,6 @@ def send_keys(self, element, arg):
:type element: Selenium object
:param arg: Text or Keys to be sent to the element
:type arg: str or selenium.webdriver.common.keys

Usage:

>>> #Defining the element:
Expand Down
2 changes: 1 addition & 1 deletion tir/technologies/core/base_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def disconnect_database(self, connection):
logger().info('DataBase connection stopped')
else:
logger().info('DataBase connection already stopped')

def query_execute(self, query, database_driver, dbq_oracle_server, database_server, database_port, database_name, database_user, database_password):
"""
Return a dictionary if the query statement is a SELECT otherwise print a number of row
Expand Down
15 changes: 11 additions & 4 deletions tir/technologies/core/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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": "Settings > Schedule > Schedule"

}

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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": "Entorno > Schedule > Schedule"

}
russian = {
"User": "Пользователь",
Expand Down Expand Up @@ -462,7 +468,8 @@ def get_language_pack(self, language):
"Code": "Код",
"Success": "успех",
"Procedure Install": "Установить выбранные процессы",
"Procedure Uninstall": "Удалить выбранные процессы"
"Procedure Uninstall": "Удалить выбранные процессы",
"Schedule Menu": "Settings > Schedule > Schedule"
}

if language.lower() == "en-us":
Expand Down
4 changes: 2 additions & 2 deletions tir/technologies/poui_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def user_screen(self, admin_user = False):
password_value = self.get_web_value(password())
endtime = time.time() + self.config.time_out
try_counter = 0
while (time.time() < endtime and not password_value and self.config.password != ''):
while (time.time() < endtime and not password_value.strip() and self.config.password != ''):

if try_counter == 0:
password = lambda: self.soup_to_selenium(password_element)
Expand All @@ -310,7 +310,7 @@ def user_screen(self, admin_user = False):
password_value = self.get_web_value(password())
try_counter += 1 if(try_counter < 1) else -1

if not password_value and self.config.password != '':
if not password_value.strip() and self.config.password != '':
self.restart_counter += 1
message = "Couldn't fill User input element."
self.log_error(message)
Expand Down
36 changes: 30 additions & 6 deletions tir/technologies/webapp_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,10 @@ def Setup(self, initial_program, date='', group='99', branch='01', module='', sa
logger().info(f"***System Info*** in Setup():")
system_info()

self.config.poui_login = ConfigLoader(self.config_path).poui_login
if 'POUILogin' in self.config.json_data and self.config.json_data['POUILogin'] == True:
self.config.poui_login = True
else:
self.config.poui_login = False

try:
self.service_process_bat_file()
Expand Down Expand Up @@ -861,7 +864,12 @@ def filling_date(self, shadow_root=None, container=None):
ActionChains(self.driver).key_down(Keys.CONTROL).send_keys(Keys.HOME).key_up(Keys.CONTROL).perform()
ActionChains(self.driver).key_down(Keys.CONTROL).key_down(Keys.SHIFT).send_keys(
Keys.END).key_up(Keys.CONTROL).key_up(Keys.SHIFT).perform()
self.send_keys(date(), self.config.date)

if self.config.browser.lower() == "chrome":
self.try_send_keys(date, self.config.date)
else:
self.send_keys(date(), self.config.date)

base_date_value = self.merge_date_mask(self.config.date, self.get_web_value(date()))
if self.config.poui_login:
ActionChains(self.driver).send_keys(Keys.TAB * 2).perform()
Expand Down Expand Up @@ -2884,7 +2892,6 @@ def input_value(self, field, value, ignore_case=True, name_attr=False, position=
if not check_value:
return

self.wait_blocker()
if self.check_combobox(element):
current_value = current_value[0:len(str(value))]

Expand Down Expand Up @@ -4311,6 +4318,8 @@ def SetButton(self, button, sub_item="", position=1, check_error=True):
if not soup_objects:
footer = self.find_shadow_element('footer', self.soup_to_selenium(soup), get_all=False)
buttons = self.find_shadow_element("wa-button", footer)
if not buttons:
buttons = self.driver.execute_script("return arguments[0].querySelectorAll('wa-button')", footer)
if buttons:
filtered_button = list(filter(lambda x: x.text.strip().replace('\n', '') == button.strip().replace(' \n ', ''), buttons))

Expand Down Expand Up @@ -7654,6 +7663,7 @@ def get_selected_row(self, 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 = ""):
"""
Fills the path screen with the desired path
Expand Down Expand Up @@ -8176,7 +8186,12 @@ def AddParameter(self, parameter, branch, portuguese_value, english_value="", sp
"""

logger().info(f"AddParameter: {parameter}")
twebview = True if ConfigLoader(self.config_path).poui_login else False

if 'POUILogin' in self.config.json_data and self.config.json_data['POUILogin'] == True:
twebview = True
else:
twebview = False

endtime = time.time() + self.config.time_out
halftime = ((endtime - time.time()) / 2)

Expand Down Expand Up @@ -8258,7 +8273,12 @@ def parameter_url(self, restore_backup=False):
>>> self.parameter_url(restore_backup=False)
"""
try_counter = False
twebview = True if ConfigLoader(self.config_path).poui_login else False

if 'POUILogin' in self.config.json_data and self.config.json_data['POUILogin'] == True:
twebview = True
else:
twebview = False

endtime = time.time() + self.config.time_out
halftime = ((endtime - time.time()) / 2)
function_to_call = "u_SetParam" if restore_backup is False else "u_RestorePar"
Expand Down Expand Up @@ -9461,7 +9481,10 @@ def TearDown(self):
logger().exception(str(e))
webdriver_exception = e

self.config.poui_login = ConfigLoader(self.config_path).poui_login
if 'POUILogin' in self.config.json_data and self.config.json_data['POUILogin'] == True:
self.config.poui_login = True
else:
self.config.poui_login = False

if webdriver_exception:
message = f"Wasn't possible execute self.driver.refresh() Exception: {next(iter(webdriver_exception.msg.split(':')), None)}"
Expand Down Expand Up @@ -10736,6 +10759,7 @@ def find_shadow_element(self, term, objects, get_all=True):
elements = self.driver.execute_script(script, objects)
except:
pass

return elements if elements else None

def return_soup_by_selenium(self, elements, term, selectors):
Expand Down
Loading