@@ -5637,8 +5637,8 @@ def _set_browse_filters(self, filters):
56375637 [Internal]
56385638 Open and apply filters to each field in a THF Browse component.
56395639
5640- :param filters: Dictionary or list of filters to apply, where keys are field names and values are filter values.
5641- :type filters: dict or list
5640+ :param filters: List of dictionaries representing filters to apply, where each dictionary's keys are field names and values are filter values.
5641+ :type filters: list
56425642 :param browse_div: BeautifulSoup object representing the browse container element.
56435643 :type browse_div: bs4.element.Tag
56445644 :return: None
@@ -5647,9 +5647,11 @@ def _set_browse_filters(self, filters):
56475647 Usage:
56485648
56495649 >>> # Calling the method:
5650- >>> self._filter_thf_browse(filters={'name': 'John'}, browse_div=browse_element)
5650+ >>> self._filter_thf_browse(filters=[ {'name': 'John'}] , browse_div=browse_element)
56515651 """
56525652
5653+ self ._remove_filters_from_browse ()
5654+
56535655 self .click_button (self .language .filters )
56545656
56555657 self .wait_element_timeout ('po-page-slide' , scrap_type = enum .ScrapType .CSS_SELECTOR , main_container = 'body' ,
@@ -5683,6 +5685,67 @@ def _set_browse_filters(self, filters):
56835685 self .click_button (self .language .apply_filters )
56845686
56855687
5688+ def _remove_filters_from_browse (self ):
5689+ """
5690+ [Internal]
5691+
5692+ Clicks the "Remove Filters" button in a THF Browse component to clear all applied filters.
5693+ Also checks for a po-tag element inside kendo-grid whose span text is
5694+ "Remover filtros" or "Remove filters", and clicks it when found.
5695+
5696+ :return: None
5697+ :rtype: None
5698+
5699+ Usage:
5700+
5701+ >>> # Calling the method:
5702+ >>> self._remove_filters_from_browse()
5703+ """
5704+
5705+ po_tag_filter = self ._get_po_tag (text = self .language .remove_filters , container_selector = 'kendo-grid' )
5706+ if po_tag_filter :
5707+ logger ().debug ("Found applied filters, clicking to remove filters." )
5708+ clickable = po_tag_filter .select_one ('.po-tag-wrapper.po-clickable' )
5709+ target = clickable if clickable else po_tag_filter
5710+ self .poui_click (target )
5711+ self .po_loading (self .containers_selectors ['GetCurrentContainer' ])
5712+ else :
5713+ logger ().debug ("No 'Remove Filters' found; skipping filter removal." )
5714+
5715+
5716+ def _get_po_tag (self , text : str , container_selector : str ):
5717+ """
5718+ [Internal]
5719+
5720+ Searches for a po-tag element inside a specified container whose span text matches
5721+ the given text (case-insensitive).
5722+
5723+ :param text: Text to match inside the po-tag span.
5724+ :type text: str
5725+ :param container_selector: CSS selector for the container to search within.
5726+ :type container_selector: str
5727+ :return: The matching po-tag BeautifulSoup element, or None if not found.
5728+ :rtype: bs4.element.Tag or None
5729+ """
5730+
5731+ soup = self .get_current_DOM (twebview = True )
5732+ if container_selector :
5733+ container = soup .select_one (container_selector )
5734+ else :
5735+ container = soup
5736+
5737+ if not container :
5738+ logger ().debug (f"No container found in DOM when searching for po-tag filter with selector '{ container_selector } '." )
5739+ return None
5740+
5741+ for po_tag in container .select ('po-tag' ):
5742+ span = po_tag .select_one ('.po-tag-value span' )
5743+ if span and span .text .strip ().lower () == text .strip ().lower ():
5744+ return po_tag
5745+
5746+ return None
5747+
5748+
56865749 def _fill_lookup_input (self , input_element , value : str ) -> None :
56875750 """
56885751 [Internal]
0 commit comments