Skip to content

Commit ab9bc75

Browse files
authored
Merge pull request #1889 from totvs/release/v2.6.0rc18
Release/v2.6.0rc18
2 parents dfe5352 + 7070b59 commit ab9bc75

4 files changed

Lines changed: 46 additions & 20 deletions

File tree

tir/main.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ def __init__(self, config_path="", autostart=True):
3030
self.coverage = self.config.coverage
3131
self._subscribe_routes()
3232

33+
def __getattribute__(self, name):
34+
attr = object.__getattribute__(self, name)
35+
36+
if callable(attr) and not name.startswith('_'):
37+
preserve_methods = {'SearchBrowse', 'SetButton'}
38+
if name not in preserve_methods:
39+
try:
40+
object.__getattribute__(self, 'config')._flag_is_new_browse = None
41+
except AttributeError:
42+
pass
43+
44+
return attr
45+
3346
def _subscribe_routes(self):
3447
"""Registra handlers do Router no event bus para roteamento.
3548
@@ -641,7 +654,7 @@ def SetBranch(self, branch):
641654
"""
642655
self.__webapp.SetBranch(branch)
643656

644-
def SetButton(self, button, sub_item="", position=1, check_error=True):
657+
def SetButton(self, button, sub_item="", position=1, check_error=True, is_browse=False):
645658
"""
646659
Method that clicks on a button on the screen.
647660
@@ -674,7 +687,7 @@ def SetButton(self, button, sub_item="", position=1, check_error=True):
674687
>>> # Calling the method to click on a sub item in a sub item that is inside a button.
675688
>>> oHelper.SetButton("Other Actions", "Delete, Delete")
676689
"""
677-
self.__router.SetButton(button, sub_item, position, check_error=check_error)
690+
self.__router.SetButton(button, sub_item, position, check_error=check_error, is_browse=is_browse)
678691

679692
def SetFilePath(self, value, button = ""):
680693
"""
@@ -1703,6 +1716,19 @@ def __init__(self, config_path="", autostart=True):
17031716
self.config = ConfigLoader()
17041717
self.coverage = self.config.coverage
17051718

1719+
def __getattribute__(self, name):
1720+
attr = object.__getattribute__(self, name)
1721+
1722+
if callable(attr) and not name.startswith('_'):
1723+
preserve_methods = {'SearchBrowse', 'SetButton'}
1724+
if name not in preserve_methods:
1725+
try:
1726+
object.__getattribute__(self, 'config')._flag_is_new_browse = None
1727+
except AttributeError:
1728+
pass
1729+
1730+
return attr
1731+
17061732
def ClickMenu(self, menu_item):
17071733
"""
17081734
Clicks on the menu-item of the POUI component.

tir/technologies/core/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def _initialize(self, path="config.json"):
130130
self.server_mock = str(data["ServerMock"]) if "ServerMock" in data else ""
131131
self.sso_login = ("SSOLogin" in data and bool(data["SSOLogin"]))
132132
self.new_home = ("NewHome" in data and bool(data["NewHome"]))
133+
self._flag_is_new_browse = None
133134

134135

135136
def check_keys(self, json_data):

tir/technologies/core/router.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,26 +133,25 @@ def set_log_info(self) -> None:
133133
drv = self._get_driver_instance(lambda: self.config.new_home)
134134
drv.set_log_info()
135135

136-
def SetButton(self, button, sub_item="", position=1, check_error=True) -> None:
136+
def SetButton(self, button, sub_item="", position=1, check_error=True, is_browse=False) -> None:
137137
"""Click on button using appropriate driver (POUI or WebApp)."""
138138

139-
view = self.language.view
140-
change = self.language.old_browse_edit
141-
other_actions = self.language.other_actions
142-
delete = self.language.old_browse_delete
143-
add = self.language.old_browse_insert
139+
if is_browse:
140+
use_poui = self._ensure_webapp()._is_new_browse(throw_error=False, timeout=self.config.time_out)
141+
else:
142+
use_poui = self.config._flag_is_new_browse if self.config._flag_is_new_browse is not None else False
144143

145-
new_browse_buttons = {view, change, other_actions, delete, add}
144+
# Consume flag: only first SetButton after SearchBrowse uses it.
145+
self.config._flag_is_new_browse = None
146146

147-
drv = self._get_driver_instance(
148-
lambda: button in new_browse_buttons and self._ensure_webapp()._is_new_browse(throw_error=False)
149-
)
147+
drv = self._get_driver_instance(lambda: use_poui)
150148
drv.SetButton(button, sub_item, position, check_error=check_error)
151149

152150

153151
def SearchBrowse(self, term=None, key=None, identifier=None, index=False, column=None, filters=[]) -> None:
154152

155-
drv = self._get_driver_instance(
156-
lambda: filters and self._ensure_webapp()._is_new_browse(throw_error=False)
157-
)
153+
use_poui = self._ensure_webapp()._is_new_browse(throw_error=False, timeout=self.config.time_out)
154+
self.config._flag_is_new_browse = use_poui
155+
156+
drv = self._get_driver_instance(lambda: use_poui)
158157
drv.SearchBrowse(term=term, key=key, identifier=identifier, index=index, column=column, filters=filters)

tir/technologies/webapp_internal.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,8 +2055,8 @@ def _simple_search_thf_browse(self, search_text, browse_div):
20552055
return
20562056

20572057

2058-
def _is_new_browse(self, throw_error=True):
2059-
browse_div = self._find_search_browse(throw_error=throw_error, timeout=5)
2058+
def _is_new_browse(self, throw_error=True, timeout=None):
2059+
browse_div = self._find_search_browse(throw_error=throw_error, timeout=timeout)
20602060

20612061
return browse_div.name == 'thf-grid' if browse_div else False
20622062

@@ -2129,7 +2129,7 @@ def _find_search_browse(self, panel_name=None, throw_error=True, timeout=None):
21292129

21302130
container_term = 'wa-tab-page > wa-dialog'
21312131
container = None
2132-
elements_soup = None
2132+
elements_soup = []
21332133
browse_div = []
21342134

21352135
endtime = time.time() + (timeout if timeout is not None else self.config.time_out)
@@ -2138,11 +2138,11 @@ def _find_search_browse(self, panel_name=None, throw_error=True, timeout=None):
21382138
soup = self.get_current_DOM()
21392139
containers = self.zindex_sort(soup.select(container_term), reverse=True)
21402140
container = next(iter(containers), None)
2141+
elements_soup = []
21412142

21422143
if container:
21432144
elements_soup = container.select("[style*='fwskin_seekbar_ico']")
2144-
2145-
elements_soup = list(filter(lambda x: self.element_is_displayed(x), elements_soup))
2145+
elements_soup = list(filter(lambda x: self.element_is_displayed(x), elements_soup)) if elements_soup else []
21462146

21472147
if elements_soup:
21482148
if elements_soup and len(elements_soup) - 1 >= search_index:

0 commit comments

Comments
 (0)