Skip to content

Commit

Permalink
Merge pull request #1577 from totvs/hotfix/clicktree_rightclick
Browse files Browse the repository at this point in the history
added new zindex check to click_tree right_click
  • Loading branch information
renanllisboa authored Nov 6, 2024
2 parents 672a87a + cd75360 commit 34eafda
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
23 changes: 23 additions & 0 deletions tir/technologies/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,29 @@ def search_zindex(self,element):
zindex = int(element.attrs['style'].split("z-index:")[1].split(";")[0].strip())

return zindex

def collect_zindex(self, reverse=True):
"""
returns z-index list in decrescent order by default or in crescent order if reverse is False.
"""

soup = self.get_current_DOM()

style_elements = soup.find_all(style=True)

if style_elements:
zindex_list = list(filter(lambda x: 'z-index' in x['style'], style_elements))
if zindex_list:
zindex_list_filtered = list(map(lambda x: x.attrs['style'].split('z-index')[1].split(';')[0].split(':')[1].strip(), zindex_list))
return sorted(list(map(int, zindex_list_filtered)), reverse=reverse)

def return_last_zindex(self):
"""
returns the last z-index value in the page.
"""
zindex_list = self.collect_zindex(reverse=True)
if zindex_list:
return next(iter(zindex_list), None)

def select_combo(self, element, option, index=False, shadow_root=True, locator=False):
"""
Expand Down
17 changes: 11 additions & 6 deletions tir/technologies/webapp_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8973,7 +8973,6 @@ def click_tree(self, treepath, right_click, position, tree_number):
element_click = lambda: self.soup_to_selenium(element_class_item)

if last_item:
start_time = time.time()
self.wait_blocker()
if self.webapp_shadowroot():
element_is_closed = lambda: element.get_attribute('closed') == 'true' or element.get_attribute('closed') == ''
Expand All @@ -8992,11 +8991,17 @@ def click_tree(self, treepath, right_click, position, tree_number):
success = True if is_element_acessible() else False

if success and right_click:
if self.webapp_shadowroot():
self.click(element_click(), enum.ClickType.SELENIUM,
right_click)
else:
self.send_action(action=self.click, element=element_click, right_click=right_click)
last_zindex = self.return_last_zindex()
current_zindex = last_zindex

endtime_right_click = time.time() + self.config.time_out / 3
while time.time() < endtime_right_click and last_zindex <= current_zindex:
if self.webapp_shadowroot():
self.click(element_click(), enum.ClickType.SELENIUM,
right_click)
current_zindex = self.return_last_zindex()
else:
self.send_action(action=self.click, element=element_click, right_click=right_click)
else:
self.scroll_to_element(element_click())
element_click().click()
Expand Down

0 comments on commit 34eafda

Please sign in to comment.