robo_appian 0.0.18__py3-none-any.whl → 0.0.19__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of robo_appian might be problematic. Click here for more details.
- robo_appian/components/ButtonUtils.py +22 -19
- robo_appian/components/InputUtils.py +59 -64
- robo_appian/components/LabelUtils.py +3 -2
- robo_appian/utils/ComponentUtils.py +20 -10
- {robo_appian-0.0.18.dist-info → robo_appian-0.0.19.dist-info}/METADATA +1 -1
- {robo_appian-0.0.18.dist-info → robo_appian-0.0.19.dist-info}/RECORD +8 -8
- {robo_appian-0.0.18.dist-info → robo_appian-0.0.19.dist-info}/LICENSE +0 -0
- {robo_appian-0.0.18.dist-info → robo_appian-0.0.19.dist-info}/WHEEL +0 -0
|
@@ -2,6 +2,7 @@ from selenium.webdriver.common.by import By
|
|
|
2
2
|
from selenium.webdriver.support import expected_conditions as EC
|
|
3
3
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
4
4
|
from selenium.webdriver.remote.webelement import WebElement
|
|
5
|
+
from robo_appian.utils.ComponentUtils import ComponentUtils
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class ButtonUtils:
|
|
@@ -36,32 +37,18 @@ class ButtonUtils:
|
|
|
36
37
|
"""
|
|
37
38
|
xpath = f".//button[./span[contains(translate(normalize-space(.), '\u00a0', ' '), '{label}')]]"
|
|
38
39
|
try:
|
|
39
|
-
component =
|
|
40
|
+
component = ComponentUtils.findVisibleComponentByXpath(wait, xpath)
|
|
40
41
|
except Exception as e:
|
|
41
42
|
raise RuntimeError(f"Button with label '{label}' not found or not clickable.") from e
|
|
42
43
|
return component
|
|
43
44
|
|
|
44
45
|
@staticmethod
|
|
45
|
-
def
|
|
46
|
-
"""
|
|
47
|
-
Finds a button by its label.
|
|
48
|
-
|
|
49
|
-
Parameters:
|
|
50
|
-
wait: Selenium WebDriverWait instance.
|
|
51
|
-
label: The label of the button to find.
|
|
52
|
-
label: The label of the button to find.
|
|
53
|
-
|
|
54
|
-
Returns:
|
|
55
|
-
WebElement representing the button.
|
|
56
|
-
|
|
57
|
-
Example:
|
|
58
|
-
component = ButtonUtils._findByLabelText(wait, "Submit")
|
|
59
|
-
"""
|
|
46
|
+
def __findByLabelText(wait: WebDriverWait, label: str):
|
|
60
47
|
xpath = f".//button[./span[normalize-space(.)='{label}']]"
|
|
61
48
|
try:
|
|
62
|
-
component =
|
|
49
|
+
component = ComponentUtils.findVisibleComponentByXpath(wait, xpath)
|
|
63
50
|
except Exception as e:
|
|
64
|
-
raise RuntimeError(f"Button with label '{label}' not found
|
|
51
|
+
raise RuntimeError(f"Button with label '{label}' not found.") from e
|
|
65
52
|
return component
|
|
66
53
|
|
|
67
54
|
@staticmethod
|
|
@@ -87,7 +74,7 @@ class ButtonUtils:
|
|
|
87
74
|
Example:
|
|
88
75
|
ButtonUtils.clickByLabelText(wait, "Button Label")
|
|
89
76
|
"""
|
|
90
|
-
component = ButtonUtils.
|
|
77
|
+
component = ButtonUtils.__findByLabelText(wait, label)
|
|
91
78
|
ButtonUtils.__click(wait, component)
|
|
92
79
|
|
|
93
80
|
@staticmethod
|
|
@@ -109,3 +96,19 @@ class ButtonUtils:
|
|
|
109
96
|
raise RuntimeError(f"Input button with id '{id}' not found or not clickable.") from e
|
|
110
97
|
|
|
111
98
|
ButtonUtils.__click(wait, component)
|
|
99
|
+
|
|
100
|
+
@staticmethod
|
|
101
|
+
def checkButtonExistsByLabelText(wait: WebDriverWait, label: str):
|
|
102
|
+
try:
|
|
103
|
+
ButtonUtils.__findByLabelText(wait, label)
|
|
104
|
+
except Exception:
|
|
105
|
+
return False
|
|
106
|
+
return True
|
|
107
|
+
|
|
108
|
+
@staticmethod
|
|
109
|
+
def checkButtonExistsByPartialLabelText(wait: WebDriverWait, label: str):
|
|
110
|
+
try:
|
|
111
|
+
ButtonUtils.__findByLabelText(wait, label)
|
|
112
|
+
except Exception:
|
|
113
|
+
return False
|
|
114
|
+
return True
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from robo_appian.utils.ComponentUtils import ComponentUtils
|
|
2
|
-
from selenium.webdriver.common.by import By
|
|
3
2
|
from selenium.webdriver.support import expected_conditions as EC
|
|
4
3
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
5
4
|
from selenium.webdriver.remote.webelement import WebElement
|
|
@@ -19,70 +18,53 @@ class InputUtils:
|
|
|
19
18
|
"""
|
|
20
19
|
|
|
21
20
|
@staticmethod
|
|
22
|
-
def
|
|
21
|
+
def __findComponentByPartialLabel(wait: WebDriverWait, label: str):
|
|
23
22
|
"""
|
|
24
|
-
Finds input
|
|
23
|
+
Finds an input component by its label text, allowing for partial matches.
|
|
25
24
|
|
|
26
25
|
Parameters:
|
|
27
26
|
wait: Selenium WebDriverWait instance.
|
|
28
|
-
|
|
27
|
+
label: The visible text label of the input component, allowing for partial matches.
|
|
29
28
|
|
|
30
29
|
Returns:
|
|
31
|
-
A
|
|
30
|
+
A Selenium WebElement representing the input component.
|
|
32
31
|
|
|
33
32
|
Example:
|
|
34
|
-
InputUtils.
|
|
33
|
+
InputUtils.__findInputComponentByPartialLabel(wait, "User")
|
|
35
34
|
"""
|
|
36
|
-
label_components = ComponentUtils.findComponentsByXPath(wait, xpath)
|
|
37
|
-
input_components = []
|
|
38
|
-
for label_component in label_components:
|
|
39
|
-
attribute: str = "for"
|
|
40
|
-
component_id = label_component.get_attribute(attribute) # type: ignore[reportUnknownMemberType]
|
|
41
|
-
if component_id:
|
|
42
|
-
try:
|
|
43
|
-
component = wait.until(EC.element_to_be_clickable((By.ID, component_id)))
|
|
44
|
-
input_components.append(component)
|
|
45
|
-
except Exception as e:
|
|
46
|
-
raise Exception(f"Could not find clickable input component with id '{component_id}': {e}")
|
|
47
|
-
else:
|
|
48
|
-
raise ValueError(f"Input component with label '{label_component.text}' does not have 'for' attribute.")
|
|
49
|
-
return input_components
|
|
50
|
-
|
|
51
|
-
@staticmethod
|
|
52
|
-
def __findInputComponentsByPartialLabel(wait: WebDriverWait, label: str):
|
|
53
|
-
"""Finds input components by their label text, allowing for partial matches.
|
|
54
35
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
label: The visible text label of the input component, allowing for partial matches.
|
|
36
|
+
xpath = f'.//div/label[contains(normalize-space(.), "{label}")]'
|
|
37
|
+
label_component = ComponentUtils.findVisibleComponentByXpath(wait, xpath)
|
|
58
38
|
|
|
59
|
-
|
|
60
|
-
|
|
39
|
+
input_id = label_component.get_attribute("for")
|
|
40
|
+
if input_id is None:
|
|
41
|
+
raise ValueError(f"Label component with text '{label}' does not have a 'for' attribute.")
|
|
61
42
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"""
|
|
65
|
-
xpath = f'.//div/label[contains(normalize-space(.), "{label}")]'
|
|
66
|
-
components = InputUtils.__findInputComponentsByXpath(wait, xpath)
|
|
67
|
-
return components
|
|
43
|
+
component = ComponentUtils.findComponentById(wait, input_id)
|
|
44
|
+
return component
|
|
68
45
|
|
|
69
46
|
@staticmethod
|
|
70
|
-
def
|
|
71
|
-
"""Finds
|
|
72
|
-
|
|
47
|
+
def __findComponentByLabel(wait: WebDriverWait, label: str):
|
|
48
|
+
"""Finds a component by its label text.
|
|
73
49
|
Parameters:
|
|
74
50
|
wait: Selenium WebDriverWait instance.
|
|
75
51
|
label: The visible text label of the input component.
|
|
76
52
|
|
|
77
53
|
Returns:
|
|
78
|
-
A
|
|
54
|
+
A Selenium WebElement representing the input component.
|
|
79
55
|
|
|
80
56
|
Example:
|
|
81
|
-
InputUtils.
|
|
57
|
+
InputUtils.__findComponentByLabel(wait, "Username")
|
|
82
58
|
"""
|
|
59
|
+
|
|
83
60
|
xpath = f'.//div/label[normalize-space(.)="{label}"]'
|
|
84
|
-
|
|
85
|
-
|
|
61
|
+
label_component = ComponentUtils.findVisibleComponentByXpath(wait, xpath)
|
|
62
|
+
input_id = label_component.get_attribute("for")
|
|
63
|
+
if input_id is None:
|
|
64
|
+
raise ValueError(f"Label component with text '{label}' does not have a 'for' attribute.")
|
|
65
|
+
|
|
66
|
+
component = ComponentUtils.findComponentById(wait, input_id)
|
|
67
|
+
return component
|
|
86
68
|
|
|
87
69
|
@staticmethod
|
|
88
70
|
def _setValueByComponent(wait: WebDriverWait, component: WebElement, value: str):
|
|
@@ -102,26 +84,20 @@ class InputUtils:
|
|
|
102
84
|
return component
|
|
103
85
|
|
|
104
86
|
@staticmethod
|
|
105
|
-
def
|
|
87
|
+
def setValueByPartialLabelText(wait: WebDriverWait, label: str, value: str):
|
|
106
88
|
"""
|
|
107
|
-
Sets a value in an input component identified by its label text.
|
|
89
|
+
Sets a value in an input component identified by its partial label text.
|
|
90
|
+
|
|
108
91
|
Parameters:
|
|
109
92
|
wait: Selenium WebDriverWait instance.
|
|
110
|
-
label: The visible text label of the input component.
|
|
93
|
+
label: The visible text label of the input component (partial match).
|
|
111
94
|
value: The value to set in the input field.
|
|
95
|
+
|
|
112
96
|
Returns:
|
|
113
97
|
None
|
|
114
|
-
Example:
|
|
115
|
-
InputUtils.setValueByLabelText(wait, "Username", "test_user")
|
|
116
98
|
"""
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
InputUtils._setValueByComponent(wait, component, value)
|
|
120
|
-
|
|
121
|
-
@staticmethod
|
|
122
|
-
def setValueByPartialLabelText(wait: WebDriverWait, label: str, value: str):
|
|
123
|
-
input_components = InputUtils.__findInputComponentsByPartialLabel(wait, label)
|
|
124
|
-
InputUtils.__setValueByComponents(wait, input_components, value)
|
|
99
|
+
component = InputUtils.__findComponentByPartialLabel(wait, label)
|
|
100
|
+
InputUtils._setValueByComponent(wait, component, value)
|
|
125
101
|
|
|
126
102
|
@staticmethod
|
|
127
103
|
def setValueByLabelText(wait: WebDriverWait, label: str, value: str):
|
|
@@ -139,17 +115,17 @@ class InputUtils:
|
|
|
139
115
|
Example:
|
|
140
116
|
InputUtils.setValueByLabelText(wait, "Username", "test_user")
|
|
141
117
|
"""
|
|
142
|
-
|
|
143
|
-
InputUtils.
|
|
118
|
+
component = InputUtils.__findComponentByLabel(wait, label)
|
|
119
|
+
InputUtils._setValueByComponent(wait, component, value)
|
|
144
120
|
|
|
145
121
|
@staticmethod
|
|
146
|
-
def setValueById(wait: WebDriverWait,
|
|
122
|
+
def setValueById(wait: WebDriverWait, id: str, value: str):
|
|
147
123
|
"""
|
|
148
124
|
Sets a value in an input component identified by its ID.
|
|
149
125
|
|
|
150
126
|
Parameters:
|
|
151
127
|
wait: Selenium WebDriverWait instance.
|
|
152
|
-
|
|
128
|
+
id: The ID of the input component.
|
|
153
129
|
value: The value to set in the input field.
|
|
154
130
|
|
|
155
131
|
Returns:
|
|
@@ -158,9 +134,28 @@ class InputUtils:
|
|
|
158
134
|
Example:
|
|
159
135
|
InputUtils.setValueById(wait, "inputComponentId", "test_value")
|
|
160
136
|
"""
|
|
161
|
-
try:
|
|
162
|
-
|
|
163
|
-
except Exception as e:
|
|
164
|
-
|
|
137
|
+
# try:
|
|
138
|
+
# component = wait.until(EC.element_to_be_clickable((By.ID, component_id)))
|
|
139
|
+
# except Exception as e:
|
|
140
|
+
# raise Exception(f"Timeout or error finding input component with id '{component_id}': {e}")
|
|
141
|
+
component = ComponentUtils.findComponentById(wait, id)
|
|
142
|
+
InputUtils._setValueByComponent(wait, component, value)
|
|
143
|
+
|
|
144
|
+
@staticmethod
|
|
145
|
+
def setValueByPlaceholderText(wait: WebDriverWait, text: str, value: str):
|
|
146
|
+
"""Sets a value in an input component identified by its placeholder text.
|
|
147
|
+
|
|
148
|
+
Parameters:
|
|
149
|
+
wait: Selenium WebDriverWait instance.
|
|
150
|
+
text: The placeholder text of the input component.
|
|
151
|
+
value: The value to set in the input field.
|
|
152
|
+
|
|
153
|
+
Returns:
|
|
154
|
+
None
|
|
155
|
+
|
|
156
|
+
Example:
|
|
157
|
+
InputUtils.setValueByPlaceholderText(wait, "Enter your name", "John Doe")
|
|
158
|
+
"""
|
|
159
|
+
xpath = f'.//input[@placeholder="{text}"]'
|
|
160
|
+
component = ComponentUtils.findVisibleComponentByXpath(wait, xpath)
|
|
165
161
|
InputUtils._setValueByComponent(wait, component, value)
|
|
166
|
-
return component
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
from selenium.webdriver.common.by import By
|
|
2
1
|
from selenium.webdriver.support import expected_conditions as EC
|
|
3
2
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
3
|
+
from robo_appian.utils.ComponentUtils import ComponentUtils
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class LabelUtils:
|
|
@@ -26,7 +26,8 @@ class LabelUtils:
|
|
|
26
26
|
"""
|
|
27
27
|
xpath = f".//*[normalize-space(.)='{label}']"
|
|
28
28
|
try:
|
|
29
|
-
component = wait.until(EC.visibility_of_element_located((By.XPATH, xpath)))
|
|
29
|
+
# component = wait.until(EC.visibility_of_element_located((By.XPATH, xpath)))
|
|
30
|
+
component = ComponentUtils.findVisibleComponentByXpath(wait, xpath)
|
|
30
31
|
except Exception as e:
|
|
31
32
|
raise RuntimeError(f"Label with text '{label}' not found.") from e
|
|
32
33
|
|
|
@@ -73,21 +73,31 @@ class ComponentUtils:
|
|
|
73
73
|
xpath = "//button[@id='submit']"
|
|
74
74
|
ComponentUtils.findComponentUsingXpathAndClick(wait, xpath)
|
|
75
75
|
"""
|
|
76
|
-
component = ComponentUtils.
|
|
76
|
+
component = ComponentUtils.findVisibleComponentByXpath(wait, xpath)
|
|
77
77
|
component.click()
|
|
78
78
|
|
|
79
79
|
@staticmethod
|
|
80
|
-
def
|
|
81
|
-
|
|
80
|
+
def findComponentById(wait: WebDriverWait, id: str):
|
|
81
|
+
try:
|
|
82
|
+
component = wait.until(EC.presence_of_element_located((By.ID, id)))
|
|
83
|
+
except Exception:
|
|
84
|
+
raise Exception(f"Component with ID '{id}' not found.")
|
|
85
|
+
return component
|
|
86
|
+
|
|
87
|
+
@staticmethod
|
|
88
|
+
def findVisibleComponentByXpath(wait: WebDriverWait, xpath: str):
|
|
89
|
+
"""
|
|
90
|
+
Finds a component using the given XPath in the current WebDriver instance.
|
|
91
|
+
|
|
92
|
+
:param wait: WebDriverWait instance to wait for elements
|
|
93
|
+
:param xpath: XPath string to locate the component
|
|
94
|
+
:return: WebElement if found, raises NoSuchElementException otherwise
|
|
82
95
|
|
|
83
|
-
:param wait: WebDriverWait instance to wait for elements
|
|
84
|
-
:param xpath: XPath string to locate the component
|
|
85
|
-
:return: WebElement if found, raises NoSuchElementException otherwise
|
|
86
96
|
Example usage:
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
component = ComponentUtils.findVisibleComponentByXpath(wait, "//button[@id='submit']")
|
|
98
|
+
component.click()
|
|
89
99
|
"""
|
|
90
|
-
component = wait.until(EC.
|
|
100
|
+
component = wait.until(EC.visibility_of_element_located((By.XPATH, xpath)))
|
|
91
101
|
return component
|
|
92
102
|
|
|
93
103
|
@staticmethod
|
|
@@ -95,7 +105,7 @@ class ComponentUtils:
|
|
|
95
105
|
"""Checks if a component with the given XPath exists in the current WebDriver instance."""
|
|
96
106
|
status = False
|
|
97
107
|
try:
|
|
98
|
-
ComponentUtils.
|
|
108
|
+
ComponentUtils.findVisibleComponentByXpath(wait, xpath)
|
|
99
109
|
status = True
|
|
100
110
|
except NoSuchElementException:
|
|
101
111
|
pass
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
robo_appian/__init__.py,sha256=6u9n2W7P1IKSSr5IPGsg7LhVR1o1uYv424mXDjJLgb0,720
|
|
2
|
-
robo_appian/components/ButtonUtils.py,sha256=
|
|
2
|
+
robo_appian/components/ButtonUtils.py,sha256=4zF7lDvn1DMIX3nI7Nl9glC1NYfFpvVj43a8N215Bx4,3990
|
|
3
3
|
robo_appian/components/DateUtils.py,sha256=3iptq3IDCy4IwefEyPtvEQ1nUFI1OVpTF3dAnViHIoM,3258
|
|
4
4
|
robo_appian/components/DropdownUtils.py,sha256=X_ucR4uCiU3fnsMXGnJC9PTfwbfW3w3ulzyuURh1Vlw,11149
|
|
5
|
-
robo_appian/components/InputUtils.py,sha256=
|
|
6
|
-
robo_appian/components/LabelUtils.py,sha256=
|
|
5
|
+
robo_appian/components/InputUtils.py,sha256=78O7G8mNjEBVdrZUjlL9PMvDzTZ9uHEm0rDB5MsuYRQ,6050
|
|
6
|
+
robo_appian/components/LabelUtils.py,sha256=d0IUm330RokFRny3CdRGNOzGtDHYqZT0WzVS1TgSscI,1958
|
|
7
7
|
robo_appian/components/LinkUtils.py,sha256=_m9dpHW9mUJFMcLp95K2s-YDYAvG-RlPF6giw3dmYcE,1389
|
|
8
8
|
robo_appian/components/SearchDropdownUtils.py,sha256=rjsC3kd8Z-eHAAzF4OBJVchStRV5pCB2dtpVEL6cdCQ,4519
|
|
9
9
|
robo_appian/components/SearchInputUtils.py,sha256=7sI8D6MXDzBPwbkIQodtxvXD2aA-8HiqvDCEJUlekZo,3263
|
|
@@ -14,9 +14,9 @@ robo_appian/controllers/ComponentDriver.py,sha256=jNaQrbKCFFyahpLKmipsA0v3p3bpjy
|
|
|
14
14
|
robo_appian/controllers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
15
|
robo_appian/exceptions/MyCustomError.py,sha256=DVAkytXNNQNjqyTyCjk6FFd6fr3AsBe57Y19erDSqVs,222
|
|
16
16
|
robo_appian/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
-
robo_appian/utils/ComponentUtils.py,sha256=
|
|
17
|
+
robo_appian/utils/ComponentUtils.py,sha256=AR9Z_RYH939KZv4yX2cpilIaZ83-DVXWCYUcuke81iE,7424
|
|
18
18
|
robo_appian/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
-
robo_appian-0.0.
|
|
20
|
-
robo_appian-0.0.
|
|
21
|
-
robo_appian-0.0.
|
|
22
|
-
robo_appian-0.0.
|
|
19
|
+
robo_appian-0.0.19.dist-info/LICENSE,sha256=g-xR4dRa9_4iFkMoJmED-wE-J5hoxbk3105Knhfpjm0,1068
|
|
20
|
+
robo_appian-0.0.19.dist-info/METADATA,sha256=RW32QbdJS10nDZOjv74t8j_E0VeQe-Cn7pHjjUxSXSU,2261
|
|
21
|
+
robo_appian-0.0.19.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
22
|
+
robo_appian-0.0.19.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|