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
47 changes: 34 additions & 13 deletions tir/technologies/poui_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3740,20 +3740,38 @@ def return_index_element(self, element):
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):
def _po_loading(self, selector: str = '') -> None:
"""

:return:
[Internal]

Waits for po-loading component to disappear, indicating that the page loading is complete.

Searches within a specified container (or entire body if not specified) and waits for
the po-loading element to be absent from the DOM.

:param selector: CSS selector of the container to monitor. If empty, searches entire body. - **Default:** '' (empty string)
:type selector: str

:return: None
:rtype: None

Usage:

>>> # Wait for loading to complete in entire page
>>> self._po_loading()
>>> # Wait for loading to complete within a specific dialog
>>> self._po_loading('wa-dialog')
"""
loading = True

endtime = time.time() + 300
while loading and time.time() < endtime:
container = self.web_scrap(term=selector, scrap_type=enum.ScrapType.CSS_SELECTOR,
main_container='body')
logger().info("Waiting loading...")

loading = True if list(filter(lambda x: x.select('po-loading'), container)) else False
main_container = selector or 'body'

self.wait_element(term='po-loading', scrap_type=enum.ScrapType.CSS_SELECTOR,
presence=False, main_container=main_container)

logger().info("Loading finished!")

def click_select(self, field, value, position):
"""

Expand Down Expand Up @@ -4503,7 +4521,7 @@ def return_table(self, selector, table_number):

table_number -= 1

self.po_loading(selector='wa-dialog')
self._po_loading()

self.wait_element(term=selector, scrap_type=enum.ScrapType.CSS_SELECTOR)

Expand Down Expand Up @@ -5364,7 +5382,7 @@ def set_program(self, program_name: str = "", program_desc: str = ""):
main_container='body')), None)

self.InputValue(self.language.input_set_program, program_name or program_desc, 1, exec_enter_tab=False)
self.po_loading(self.containers_selectors['GetCurrentContainer'])
self._po_loading()
if not program_name and program_desc:
self.config.routine = self._get_program_by_desc(program_desc)
self.click_po_list_box(value=program_desc, second_value=program_name, program_call=True)
Expand Down Expand Up @@ -5652,6 +5670,8 @@ def _set_browse_filters(self, filters):
>>> self._filter_thf_browse(filters=[{'name': 'John'}], browse_div=browse_element)
"""

self._po_loading()

self._remove_filters_from_browse()

self.click_button(self.language.filters)
Expand Down Expand Up @@ -5718,7 +5738,7 @@ def _remove_filters_from_browse(self):
clickable = po_tag_filter.select_one('.po-tag-wrapper.po-clickable')
target = clickable if clickable else po_tag_filter
self.poui_click(target)
self.po_loading(self.containers_selectors['GetCurrentContainer'])
self._po_loading()
else:
logger().debug("No 'Remove Filters' found; skipping filter removal.")

Expand Down Expand Up @@ -5923,7 +5943,8 @@ def SetButton(self, button, sub_item="", position=1, check_error=True):
:type check_error: bool
"""

logger().info("Switching to the POUI button-click method")
self._po_loading()

button_normalized = str(button).lower().strip() if button is not None else ""
sub_item_normalized = str(sub_item).lower().strip() if sub_item is not None else ""

Expand Down
2 changes: 0 additions & 2 deletions tir/technologies/webapp_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2172,13 +2172,11 @@ def _simple_search_thf_browse(self, search_text, browse_div):
self.log_error(f"_simple_search_thf_browse: couldn't fill search input with value '{search_text}'")
return


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


def longest_word(self, string):
words = string.split()

Expand Down
Loading