Spaces:
Running
Running
Update tools/interact_element.py
Browse files- tools/interact_element.py +7 -12
tools/interact_element.py
CHANGED
@@ -6,23 +6,18 @@ class InteractElementTool(Tool):
|
|
6 |
name = "interact_element"
|
7 |
description = "Interacts with a web element (click, fill text, press keys)."
|
8 |
inputs = {
|
9 |
-
"selector": {"type": "
|
10 |
-
"text": {"type": "
|
11 |
-
"action": {"type": "
|
12 |
-
"input_text": {"type": "
|
13 |
-
"key": {"type": "
|
14 |
}
|
15 |
-
output_type = "
|
16 |
|
17 |
def __init__(self, driver):
|
18 |
self.driver = driver
|
19 |
|
20 |
-
def forward(self,
|
21 |
-
selector = kwargs.get("selector")
|
22 |
-
text = kwargs.get("text")
|
23 |
-
action = kwargs.get("action", "click")
|
24 |
-
input_text = kwargs.get("input_text")
|
25 |
-
key = kwargs.get("key")
|
26 |
try:
|
27 |
if selector:
|
28 |
element = self.driver.find_element(By.CSS_SELECTOR, selector)
|
|
|
6 |
name = "interact_element"
|
7 |
description = "Interacts with a web element (click, fill text, press keys)."
|
8 |
inputs = {
|
9 |
+
"selector": {"type": "string", "default": None, "description": "CSS selector to target element"},
|
10 |
+
"text": {"type": "string", "default": None, "description": "Text to locate element"},
|
11 |
+
"action": {"type": "string", "default": "click", "description": "Action: 'click', 'fill', or 'press'"},
|
12 |
+
"input_text": {"type": "string", "default": None, "description": "Text to input for fill action"},
|
13 |
+
"key": {"type": "string", "default": None, "description": "Key to press (e.g., 'ENTER')"}
|
14 |
}
|
15 |
+
output_type = "string"
|
16 |
|
17 |
def __init__(self, driver):
|
18 |
self.driver = driver
|
19 |
|
20 |
+
def forward(self, selector=None, text=None, action="click", input_text=None, key=None):
|
|
|
|
|
|
|
|
|
|
|
21 |
try:
|
22 |
if selector:
|
23 |
element = self.driver.find_element(By.CSS_SELECTOR, selector)
|