Skip to content
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
30 changes: 28 additions & 2 deletions tir/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ def __init__(self, config_path="", autostart=True):
self.coverage = self.config.coverage
self._subscribe_routes()

def __getattribute__(self, name):
attr = object.__getattribute__(self, name)

if callable(attr) and not name.startswith('_'):
preserve_methods = {'SearchBrowse', 'SetButton'}
if name not in preserve_methods:
try:
object.__getattribute__(self, 'config')._flag_is_new_browse = None
except AttributeError:
pass

return attr

def _subscribe_routes(self):
"""Registra handlers do Router no event bus para roteamento.

Expand Down Expand Up @@ -641,7 +654,7 @@ def SetBranch(self, branch):
"""
self.__webapp.SetBranch(branch)

def SetButton(self, button, sub_item="", position=1, check_error=True):
def SetButton(self, button, sub_item="", position=1, check_error=True, is_browse=False):
"""
Method that clicks on a button on the screen.

Expand Down Expand Up @@ -674,7 +687,7 @@ def SetButton(self, button, sub_item="", position=1, check_error=True):
>>> # Calling the method to click on a sub item in a sub item that is inside a button.
>>> oHelper.SetButton("Other Actions", "Delete, Delete")
"""
self.__router.SetButton(button, sub_item, position, check_error=check_error)
self.__router.SetButton(button, sub_item, position, check_error=check_error, is_browse=is_browse)

def SetFilePath(self, value, button = ""):
"""
Expand Down Expand Up @@ -1703,6 +1716,19 @@ def __init__(self, config_path="", autostart=True):
self.config = ConfigLoader()
self.coverage = self.config.coverage

def __getattribute__(self, name):
attr = object.__getattribute__(self, name)

if callable(attr) and not name.startswith('_'):
preserve_methods = {'SearchBrowse', 'SetButton'}
if name not in preserve_methods:
try:
object.__getattribute__(self, 'config')._flag_is_new_browse = None
except AttributeError:
pass

return attr

def ClickMenu(self, menu_item):
"""
Clicks on the menu-item of the POUI component.
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 @@ -130,6 +130,7 @@ def _initialize(self, path="config.json"):
self.server_mock = str(data["ServerMock"]) if "ServerMock" in data else ""
self.sso_login = ("SSOLogin" in data and bool(data["SSOLogin"]))
self.new_home = ("NewHome" in data and bool(data["NewHome"]))
self._flag_is_new_browse = None


def check_keys(self, json_data):
Expand Down
25 changes: 12 additions & 13 deletions tir/technologies/core/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,26 +133,25 @@ def set_log_info(self) -> None:
drv = self._get_driver_instance(lambda: self.config.new_home)
drv.set_log_info()

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

view = self.language.view
change = self.language.old_browse_edit
other_actions = self.language.other_actions
delete = self.language.old_browse_delete
add = self.language.old_browse_insert
if is_browse:
use_poui = self._ensure_webapp()._is_new_browse(throw_error=False, timeout=self.config.time_out)
else:
use_poui = self.config._flag_is_new_browse if self.config._flag_is_new_browse is not None else False

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

drv = self._get_driver_instance(
lambda: button in new_browse_buttons and self._ensure_webapp()._is_new_browse(throw_error=False)
)
drv = self._get_driver_instance(lambda: use_poui)
drv.SetButton(button, sub_item, position, check_error=check_error)


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

drv = self._get_driver_instance(
lambda: filters and self._ensure_webapp()._is_new_browse(throw_error=False)
)
use_poui = self._ensure_webapp()._is_new_browse(throw_error=False, timeout=self.config.time_out)
self.config._flag_is_new_browse = use_poui

drv = self._get_driver_instance(lambda: use_poui)
drv.SearchBrowse(term=term, key=key, identifier=identifier, index=index, column=column, filters=filters)
10 changes: 5 additions & 5 deletions tir/technologies/webapp_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2055,8 +2055,8 @@ def _simple_search_thf_browse(self, search_text, browse_div):
return


def _is_new_browse(self, throw_error=True):
browse_div = self._find_search_browse(throw_error=throw_error, timeout=5)
def _is_new_browse(self, throw_error=True, timeout=None):
browse_div = self._find_search_browse(throw_error=throw_error, timeout=timeout)

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

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

container_term = 'wa-tab-page > wa-dialog'
container = None
elements_soup = None
elements_soup = []
browse_div = []

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

if container:
elements_soup = container.select("[style*='fwskin_seekbar_ico']")

elements_soup = list(filter(lambda x: self.element_is_displayed(x), elements_soup))
elements_soup = list(filter(lambda x: self.element_is_displayed(x), elements_soup)) if elements_soup else []

if elements_soup:
if elements_soup and len(elements_soup) - 1 >= search_index:
Expand Down
Loading