Skip to content

Commit

Permalink
Merge pull request #1376 from totvs/release/v1.20.16
Browse files Browse the repository at this point in the history
Release/v1.20.16
  • Loading branch information
98llm authored Dec 29, 2023
2 parents 8e4c5d5 + 280ec05 commit 89c6cbe
Show file tree
Hide file tree
Showing 8 changed files with 377 additions and 34 deletions.
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.15.tar.gz
pip install -U dist/tir_framework-1.20.16.tar.gz
pause >nul | set/p = Press any key to exit ...
44 changes: 44 additions & 0 deletions tir/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,50 @@ def ClickByLocator(self, selector='', locator='', right_click=False):
:return: None
"""
return self.__webapp.click_by_locator(selector, locator, right_click, shadow_root=True)

def AddProcedure(self, procedure, group):
"""
Install/Desinstall a procedure in CFG to be set by SetProcedures method.
:param procedure: The procedure to be clicked in edit screen.
:type branch: str
:param group: The group name.
:type parameter: str
Usage:
>>> # Calling the method:
>>> oHelper.AddProcedure("01", "T1")
"""
return self.__webapp.AddProcedure(procedure, group)

def SetProcedures(self, is_procedure_install=True):
"""
Sets the procedures in CFG screen. The procedures must be passed with calls for **AddProcedure** method.
Usage:
:param is_procedure_install: If True will install the procedure.
:type branch: str
>>> # Adding procedures:
>>> oHelper.AddProcedure("19", "T1")
>>> # Calling the method:
>>> oHelper.SetProcedures(is_procedure_install=True)
"""
return self.__webapp.SetProcedures(is_procedure_install)


def GetLineNumber(self, values, columns=[], grid_number=0):
"""
:param values: values composition expected in respective columns
:param columns: reference columns used to get line
:param grid_number:
:return:
"""
return self.__webapp.GetLineNumber(values,columns, grid_number)


class Apw():

Expand Down
23 changes: 17 additions & 6 deletions tir/technologies/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ def __init__(self, config_path="", autostart=True):
import getpass
self.log.user = getpass.getuser()

if self.config.smart_test:
if self.log.user == 'root':
self.log.user = 'advpr.sp'

self.base_container = "body"
self.config.log_file = False
self.tmenu_out_iframe = False
Expand Down Expand Up @@ -1156,6 +1160,11 @@ def Start(self):

self.get_url()

if self.driver:
window_size = self.driver.get_window_size()
logger().info(f"Browser maximized to {window_size['width']}x{window_size['height']}")
if window_size and not 768 in range(window_size['height'], window_size['height']+ 40):
logger().info(f"Screen size is different from default used in headless mode")
self.wait = WebDriverWait(self.driver, self.config.time_out)

if not self.config.poui:
Expand All @@ -1170,15 +1179,17 @@ def get_url(self, url=None):

url = self.config.url if not url else url

endtime = time.time() + self.config.time_out
while (time.time() < endtime and not get_url):

logger().debug('Get URL')
num_of_trying = 1
while not get_url and num_of_trying <= 5:
self.driver.get(url)
try:
self.driver.get(url)
WebDriverWait(self.driver, int(self.config.time_out / num_of_trying)).until(EC.presence_of_element_located((By.ID, 'fieldsetStartProg')))
logger().info("Page is ready!")
get_url = True
break
except:
get_url = False
num_of_trying += 1
logger().info(f"Loading took too much time! num_of_trying: {str(num_of_trying)}")

def TearDown(self):
"""
Expand Down
1 change: 1 addition & 0 deletions tir/technologies/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ def __init__(self, path="config.json"):
self.ssl_chrome_auto_install_disable = (
"SSLChromeInstallDisable" in data and bool(data["SSLChromeInstallDisable"]))
self.data_delimiter = str(data["DataDelimiter"]) if "DataDelimiter" in data else "/"
self.procedure_menu = str(data["ProcedureMenu"]) if "ProcedureMenu" in data else ""
39 changes: 32 additions & 7 deletions tir/technologies/core/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ def __init__(self, language="pt-BR"):
self.ref_dt = languagepack["Ref.Dt"]
self.time = languagepack["Time"]
self.end_time = languagepack["End Time"]


self.procedure_menu = languagepack["Procedure Menu"]
self.code = languagepack["Code"]
self.success = languagepack["Success"]
self.procedure_install = languagepack["Procedure Install"]
self.procedure_uninstall = languagepack["Procedure Uninstall"]

self.messages = Messages(languagepack)

def get_language_pack(self, language):
Expand Down Expand Up @@ -173,7 +177,13 @@ def get_language_pack(self, language):
"Issued": "Issued",
"Ref.Dt": "Ref.Dt",
"Time": "Time",
"End Time": "End Time"
"End Time": "End Time",
"Procedure Menu": "Database > Dictionary > Stored Procedure",
"Code": "Code",
"Success": "Success",
"Procedure Install": "Install selected processes",
"Procedure Uninstall": "Remove selected processes"

}

brazilian_portuguese = {
Expand Down Expand Up @@ -261,7 +271,12 @@ def get_language_pack(self, language):
"Issued": "Emissão",
"Ref.Dt": "DT.Ref.",
"Time": "Hora",
"End Time": "Hora Término"
"End Time": "Hora Término",
"Procedure Menu": "Base de Dados > Dicionário > Stored Procedure",
"Code": "Código",
"Success": "Sucessos",
"Procedure Install": "Instalar processos selecionados",
"Procedure Uninstall": "Remover processos selecionados"
}
spanish = {
"User": "Usuário",
Expand Down Expand Up @@ -348,12 +363,17 @@ def get_language_pack(self, language):
"Issued": "Emision",
"Ref.Dt": "Fc.Ref.",
"Time": "Hora",
"End Time": "Hora Término"
"End Time": "Hora Término",
"Procedure Menu": "Base de Dados > Dicionário > Stored Procedure",
"Code": "Código",
"Success": "Sucessos",
"Procedure Install": "Instalar processos selecionados",
"Procedure Uninstall": "Remover processos selecionados"
}
russian = {
"User": "Пользователь",
"Password": "Пароль",
"Database": "Дата",
"Database": "Базовая дата",
"Group": "Группа",
"Branch": "Филиал",
"Environment": "Среда",
Expand Down Expand Up @@ -437,7 +457,12 @@ def get_language_pack(self, language):
"Issued": "Issued",
"Ref.Dt": "Ref.Dt",
"Time": "Time",
"End Time": "End Time"
"End Time": "End Time",
"Procedure Menu": "Database > Dictionary > Stored Procedure",
"Code": "Код",
"Success": "успех",
"Procedure Install": "Установить выбранные процессы",
"Procedure Uninstall": "Удалить выбранные процессы"
}

if language.lower() == "en-us":
Expand Down
47 changes: 32 additions & 15 deletions tir/technologies/poui_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,8 @@ def CheckResult(self, field, user_value, po_component, position):
"""

if po_component == 'po-input':
input_field = self.return_input_element(field, position)
po_component = "[class*='po-input']"
input_field = self.return_input_element(field, position, term=po_component)
input_field_element = lambda: self.soup_to_selenium(input_field, twebview=True)
if input_field_element():
current_value = self.get_web_value(input_field_element())
Expand Down Expand Up @@ -3104,20 +3105,34 @@ def InputValue(self, field, value, position):
"""

logger().info(f"Input Value in:'{field}'")

input_field = self.return_input_element(field, position, term="[class*='po-input']")

self.switch_to_iframe()
success = False

endtime = time.time() + self.config.time_out
while time.time() < endtime and not success:

input_field = self.return_input_element(field, position, term="[class*='po-input']")

input_field_element = lambda: self.soup_to_selenium(input_field)
self.switch_to_iframe()

input_field_element = lambda: self.soup_to_selenium(input_field)

self.scroll_to_element(input_field_element())
self.wait_until_to(expected_condition="element_to_be_clickable", element = input_field, locator = By.XPATH )
self.set_element_focus(input_field_element())
self.wait_until_to(expected_condition="element_to_be_clickable", element = input_field, locator = By.XPATH )
self.click(input_field_element())
input_field_element().clear()
input_field_element().send_keys(value)

if self.driver.switch_to_active_element() == input_field_element():
time.sleep(1)
ActionChains(self.driver).key_down(Keys.ENTER).perform()
time.sleep(1)
ActionChains(self.driver).key_down(Keys.TAB).perform()

self.scroll_to_element(input_field_element())
self.wait_until_to(expected_condition="element_to_be_clickable", element = input_field, locator = By.XPATH )
self.set_element_focus(input_field_element())
self.wait_until_to(expected_condition="element_to_be_clickable", element = input_field, locator = By.XPATH )
self.click(input_field_element())
input_field_element().clear()
input_field_element().send_keys(value)
time.sleep(2)
success = self.get_web_value(input_field_element()).strip() != ''

def return_input_element(self, field=None, position=1, term=None):
"""
Expand Down Expand Up @@ -3166,15 +3181,17 @@ def return_main_element(self, field, position, selector, container):
else:
po_component_span = list(filter(lambda x: field.lower() in x.text.lower(), po_component))
if len(po_component_span) > 1:
po_component_span = list(filter(lambda x: self.return_index_element(x), po_component_span))
has_index = list(filter(lambda x: self.return_index_element(x), po_component_span))
if has_index:
po_component_span = has_index

if len(po_component_span) >= position:
po_component_span = po_component_span[position]
return next(iter(po_component_span.find_parent('po-field-container')), None) if container else po_component_span

def return_index_element(self, element):
if hasattr(element.find_parent('div', class_='po-modal-content'), 'attrs'):
return element if element.find_parent('div', class_='po-modal-content').attrs['tabindex'] == '-1' else None
if hasattr(element.find_parent('div', {'tabindex': '-1'}), 'attr'):
return element if element.find_parent('div', {'tabindex': '-1'}) else None

def po_loading(self, selector):
"""
Expand Down
Loading

0 comments on commit 89c6cbe

Please sign in to comment.