Skip to content

Commit

Permalink
Merge pull request #1440 from totvs/hotfix/setbutton_x
Browse files Browse the repository at this point in the history
fix setButton x
  • Loading branch information
98llm committed Jun 28, 2024
2 parents 0301ad9 + a63a28c commit 44a9b02
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tir/technologies/webapp_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4451,9 +4451,10 @@ def set_button_x(self, position=1, check_error=True):
element_soup = close_list.pop(position)
element_selenium = self.soup_to_selenium(element_soup)
if self.webapp_shadowroot():
if element_selenium.get_attribute('title') == self.language.warning or ('fundodlg_mdi.png' in element_selenium.value_of_css_property('--wa-dialog-background-image') and element_selenium.tag_name == 'wa-dialog') :
script = "return arguments[0].shadowRoot.querySelector('wa-dialog-header').shadowRoot.querySelector('button')"
element_selenium = self.driver.execute_script(script, element_selenium)
header = self.find_shadow_element('wa-dialog-header', element_selenium, get_all=False)
x_button = self.find_shadow_element("button[class~=button-close]", header, get_all=False)
if x_button:
element_selenium = x_button

self.scroll_to_element(element_selenium)
self.wait_until_to(expected_condition="element_to_be_clickable", element=element_soup, locator=By.XPATH)
Expand Down Expand Up @@ -10499,11 +10500,14 @@ def find_child_element(self, term, element):
raise ValueError(message)


def find_shadow_element(self, term, objects):
def find_shadow_element(self, term, objects, get_all=True):

elements = None
if get_all:
script = f"return arguments[0].shadowRoot.querySelectorAll('{term}')"
else:
script = f"return arguments[0].shadowRoot.querySelector('{term}')"

script = f"return arguments[0].shadowRoot.querySelectorAll('{term}')"
try:
elements = self.driver.execute_script(script, objects)
except:
Expand Down

0 comments on commit 44a9b02

Please sign in to comment.