Skip to content

Commit

Permalink
fix chrome input
Browse files Browse the repository at this point in the history
  • Loading branch information
98llm committed Dec 31, 2024
1 parent 03ba3b3 commit 99deeaf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
23 changes: 5 additions & 18 deletions tir/technologies/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ def return_selected_combo_value(self, element):
else:
return ''

def send_keys(self, element, arg, send_type=1):
def send_keys(self, element, arg):
"""
[Internal]
Expand All @@ -902,8 +902,6 @@ def send_keys(self, element, arg, send_type=1):
:type element: Selenium object
:param arg: Text or Keys to be sent to the element
:type arg: str or selenium.webdriver.common.keys
:param send_type: Send Keys type can be do it Selenium or ActionChains
:type send_type: Int
Usage:
>>> #Defining the element:
Expand All @@ -914,21 +912,10 @@ def send_keys(self, element, arg, send_type=1):
>>> self.send_keys(element(), Keys.ENTER)
"""
try:
if send_type == 1:
if arg.isprintable():
element.clear()
element.send_keys(Keys.CONTROL, 'a')
element.send_keys(arg)
elif send_type == 2:
actions = ActionChains(self.driver)
actions.move_to_element(element)
actions.click()
if arg.isprintable():
actions.key_down(Keys.CONTROL).send_keys('a').key_up(Keys.CONTROL).send_keys(Keys.DELETE)
actions.send_keys(Keys.HOME)
actions.send_keys(arg)
actions.perform()

if arg.isprintable():
element.clear()
element.send_keys(Keys.CONTROL, 'a')
element.send_keys(arg)
except Exception:
actions = ActionChains(self.driver)
actions.move_to_element(element)
Expand Down
8 changes: 3 additions & 5 deletions tir/technologies/webapp_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ def filling_date(self, shadow_root=None, container=None):
Keys.END).key_up(Keys.CONTROL).key_up(Keys.SHIFT).perform()

if self.config.browser.lower() == "chrome":
self.send_keys(date(), self.config.date, send_type=2)
self.try_send_keys(date, self.config.date)
else:
self.send_keys(date(), self.config.date)

Expand Down Expand Up @@ -4318,6 +4318,8 @@ def SetButton(self, button, sub_item="", position=1, check_error=True):
if not soup_objects:
footer = self.find_shadow_element('footer', self.soup_to_selenium(soup), get_all=False)
buttons = self.find_shadow_element("wa-button", footer)
if not buttons:
buttons = self.driver.execute_script("return arguments[0].querySelectorAll('wa-button')", footer)
if buttons:
filtered_button = list(filter(lambda x: x.text.strip().replace('\n', '') == button.strip().replace(' \n ', ''), buttons))

Expand Down Expand Up @@ -10757,10 +10759,6 @@ def find_shadow_element(self, term, objects, get_all=True):
elements = self.driver.execute_script(script, objects)
except:
pass

if not elements:
script = f"return arguments[0].querySelectorAll('{term}')"
elements = self.driver.execute_script(script, objects)

return elements if elements else None

Expand Down

0 comments on commit 99deeaf

Please sign in to comment.