Skip to content

Commit

Permalink
Merge pull request #1436 from totvs/release/v1.20.20
Browse files Browse the repository at this point in the history
Release/v1.20.20
  • Loading branch information
renanllisboa authored Jun 25, 2024
2 parents e4da9ec + abe6f95 commit 4f92b74
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 40 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.19.tar.gz
pip install -U dist/tir_framework-1.20.20.tar.gz
pause >nul | set/p = Press any key to exit ...
29 changes: 29 additions & 0 deletions tir/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1905,3 +1905,32 @@ def ClickPopup(self, label):
"""
self.__poui.click_popup(label)

def WaitShow(self, string, timeout=None, throw_error = True):
"""
Search string that was sent and wait show the elements.
:param itens: String that will hold the wait.
:type string: str
:param timeout: Timeout that wait before return.
:type timeout: str
Usage:
>>> # Calling the method:
>>> oHelper.WaitShow("Processing")
"""
self.__poui.WaitShow(string, timeout, throw_error)

def WaitProcessing(self, itens, timeout=None):
"""
Uses WaitShow and WaitHide to Wait a Processing screen
:param itens: List of itens that will hold the wait.
:type itens: str
Usage:
>>> # Calling the method:
>>> oHelper.WaitProcessing("Processing")
"""
self.__poui.WaitProcessing(itens, timeout)
2 changes: 1 addition & 1 deletion tir/technologies/core/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def checks_empty_line(self):

table_rows_has_line = False

for row in range(0, len(self.table_rows[1:])):
for row in range(0, len(self.table_rows)):
if self.table_rows[row][3] == '':
self.table_rows[row][3] = 'NO PROGRAM'

Expand Down
12 changes: 8 additions & 4 deletions tir/technologies/poui_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,10 @@ def WaitHide(self, string, timeout=None, throw_error = True):

element = None

element = self.web_scrap(term=string, scrap_type=enum.ScrapType.MIXED, optional_term=".tsay, .tgroupbox", main_container = self.containers_selectors["AllContainers"], check_help=False)
element = self.web_scrap(term=string, scrap_type=enum.ScrapType.MIXED, optional_term="po-loading-overlay", main_container = self.containers_selectors["AllContainers"], check_help=False)
element = next(iter(element), None)
if hasattr(element, "attrs") and "hidden" in element.attrs:
element = []

if not element:
return
Expand Down Expand Up @@ -1848,7 +1851,7 @@ def WaitShow(self, string, timeout=None, throw_error = True):

element = None

element = self.web_scrap(term=string, scrap_type=enum.ScrapType.MIXED, optional_term=".tsay, .tgroupbox", main_container = self.containers_selectors["AllContainers"], check_help=False)
element = self.web_scrap(term=string, scrap_type=enum.ScrapType.MIXED, optional_term="po-loading-overlay, span", main_container = self.containers_selectors["AllContainers"], check_help=False)

if element:
return element
Expand Down Expand Up @@ -2278,7 +2281,7 @@ def log_error(self, message, new_log_line=True, skip_restart=False):
if self.config.coverage:
self.coverage()

if self.config.smart_test:
if self.config.smart_test or self.config.debug_log:
logger().debug(f"***System Info*** in log_error():")
system_info()

Expand Down Expand Up @@ -3334,7 +3337,8 @@ def ClickWidget(self, title, action, position):
element = po_widget[position]

if action:
element = next(iter(element.select("[class*='po-widget-action']")), None)
element = next(iter(list(filter(lambda x: action.lower() in x.text.lower(),
element.select("[class*='po-widget-action']")))), None)
else:
self.log_error("Couldn't find element")

Expand Down
71 changes: 38 additions & 33 deletions tir/technologies/webapp_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def Setup(self, initial_program, date='', group='99', branch='01', module='', sa
>>> oHelper.Setup("SIGAFAT", "18/08/2018", "T1", "D MG 01 ")
"""

if self.config.smart_test:
if self.config.smart_test or self.config.debug_log:
logger().info(f"***System Info*** in Setup():")
system_info()

Expand Down Expand Up @@ -2405,9 +2405,9 @@ def search_element_position(self, field, position=1, input_field=True, direction

label_s = lambda:self.soup_to_selenium(label)
if self.webapp_shadowroot():
xy_label = label_s().location
xy_label = lambda: label_s().location
else:
xy_label = self.driver.execute_script('return arguments[0].getPosition()', label_s())
xy_label = lambda: self.driver.execute_script('return arguments[0].getPosition()', label_s())

if input_field:
active_tab = self.filter_active_tabs(container)
Expand Down Expand Up @@ -2453,8 +2453,8 @@ def search_element_position(self, field, position=1, input_field=True, direction
list_in_range = list(filter(lambda x: field.strip().lower() != x.text.strip().lower(), list_in_range))

position_list = list(map(lambda x:(x[0], self.get_position_from_bs_element(x[1])), enumerate(list_in_range)))
position_list = self.filter_by_direction(xy_label, width_safe, height_safe, position_list, direction)
distance = self.get_distance_by_direction(xy_label, position_list, direction)
position_list = self.filter_by_direction(xy_label(), width_safe, height_safe, position_list, direction)
distance = self.get_distance_by_direction(xy_label(), position_list, direction)
if distance:
elem = min(distance, key = lambda x: abs(x[1]))
elem = list_in_range[elem[0]]
Expand Down Expand Up @@ -2990,7 +2990,8 @@ def get_web_value(self, element):
logger().debug(f"Current value: {web_value}")
return web_value

def CheckResult(self, field, user_value, grid=False, line=1, grid_number=1, name_attr=False, input_field=True, direction=None, grid_memo_field=False, position=1, ignore_case=True):
def CheckResult(self, field, user_value, grid=False, line=1, grid_number=1, name_attr=False, input_field=True,
direction=None, grid_memo_field=False, position=1, ignore_case=True):
"""
Checks if a field has the value the user expects.
Expand Down Expand Up @@ -3038,39 +3039,42 @@ def CheckResult(self, field, user_value, grid=False, line=1, grid_number=1, name
if grid:
self.check_grid_appender(line - 1, field, user_value, grid_number - 1, position, ignore_case)
elif isinstance(user_value, bool):
current_value = self.result_checkbox(field, user_value)
current_value = self.result_checkbox(field, user_value, position)
self.log_result(field, user_value, current_value)
else:
field = re.sub(r"(\:*)(\?*)", "", field).strip()
if name_attr:
self.wait_element(term=f"[name$='{field}']", scrap_type=enum.ScrapType.CSS_SELECTOR)
else:
self.wait_element(field)
endtime = time.time() + self.config.time_out
current_value = ''
while (time.time() < endtime and not current_value):
field = re.sub(r"(\:*)(\?*)", "", field).strip()
if name_attr:
self.wait_element(term=f"[name$='{field}']", scrap_type=enum.ScrapType.CSS_SELECTOR,
position=position - 1)
else:
self.wait_element(field, position=position - 1)

element = self.get_field(field, name_attr=name_attr, input_field=input_field, direction=direction)
if not element:
self.log_error(f"Couldn't find element: {field}")
element = self.get_field(field, name_attr=name_attr, input_field=input_field, direction=direction,
position=position)
if not element:
self.log_error(f"Couldn't find element: {field}")

if self.webapp_shadowroot():
field_element = lambda : self.soup_to_selenium(element)
else:
field_element = lambda: self.driver.find_element_by_xpath(xpath_soup(element))
if self.webapp_shadowroot():
field_element = lambda: self.soup_to_selenium(element)
else:
field_element = lambda: self.driver.find_element_by_xpath(xpath_soup(element))

self.set_element_focus(field_element())
self.scroll_to_element(field_element())

self.set_element_focus(field_element())
self.scroll_to_element(field_element())
endtime = time.time() + self.config.time_out
current_value = ''
while(time.time() < endtime and not current_value):
if self.get_web_value(field_element()):
current_value = self.get_web_value(field_element()).strip()

logger().info(f"Value for Field {field} is: {current_value}")

#Remove mask if present.
# Remove mask if present.
if self.check_mask(field_element()):
current_value = self.remove_mask(current_value).replace(',','')
user_value = self.remove_mask(user_value).replace(',','')
#If user value is string, Slice string to match user_value's length
current_value = self.remove_mask(current_value).replace(',', '')
user_value = self.remove_mask(user_value).replace(',', '')
# If user value is string, Slice string to match user_value's length
if type(current_value) is str:
current_value = current_value[0:len(str(user_value))]

Expand Down Expand Up @@ -3138,7 +3142,8 @@ def GetValue(self, field, grid=False, line=1, grid_number=1, grid_memo_field=Fal
value = self.get_web_value(selenium_element())
else:
field_array = [line-1, field, "", grid_number-1]
x3_dictionaries = self.create_x3_tuple()
if re.match(r"\w+(_)", field_array[1]):
x3_dictionaries = self.get_x3_dictionaries([field_array[1].strip()])
value = self.check_grid(field_array, x3_dictionaries, get_value=True, position=position)

logger().info(f"Current value: {value}")
Expand Down Expand Up @@ -4211,7 +4216,7 @@ def SetButton(self, button, sub_item="", position=1, check_error=True):
endtime = time.time() + self.config.time_out
starttime = time.time()

if self.config.smart_test:
if self.config.smart_test or self.config.debug_log:
logger().debug(f"***System Info*** Before Clicking on button:{button}")
system_info()

Expand Down Expand Up @@ -4410,7 +4415,7 @@ def SetButton(self, button, sub_item="", position=1, check_error=True):
except Exception as error:
logger().exception(str(error))

if self.config.smart_test:
if self.config.smart_test or self.config.debug_log:
logger().debug(f"***System Info*** After Clicking on button:")
system_info()

Expand Down Expand Up @@ -5895,7 +5900,7 @@ def input_grid_appender(self, column, value, grid_number=0, new=False, row=None,

self.grid_input.append([column, value, grid_number, new, row, check_value, duplicate_fields, position, ignore_case])

def check_grid_appender(self, line, column, value, grid_number=0, position=1, ignore_case=True):
def check_grid_appender(self, line, column, value=None, grid_number=0, position=1, ignore_case=True):
"""
[Internal]
Expand Down Expand Up @@ -7836,7 +7841,7 @@ def log_error(self, message, new_log_line=True, skip_restart=False):
self.clear_grid()
logger().warning(f"Warning log_error {message}")

if self.config.smart_test:
if self.config.smart_test or self.config.debug_log:
logger().debug(f"***System Info*** in log_error():")
system_info()

Expand Down
2 changes: 1 addition & 1 deletion tir/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.20.19'
__version__ = '1.20.20'

0 comments on commit 4f92b74

Please sign in to comment.