robo_appian 0.0.10__tar.gz → 0.0.12__tar.gz

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.

Files changed (28) hide show
  1. {robo_appian-0.0.10 → robo_appian-0.0.12}/PKG-INFO +1 -1
  2. {robo_appian-0.0.10 → robo_appian-0.0.12}/pyproject.toml +1 -1
  3. robo_appian-0.0.12/robo_appian/components/ButtonUtils.py +69 -0
  4. robo_appian-0.0.12/robo_appian/components/DateUtils.py +77 -0
  5. robo_appian-0.0.12/robo_appian/components/DropdownUtils.py +244 -0
  6. robo_appian-0.0.12/robo_appian/components/InputUtils.py +165 -0
  7. robo_appian-0.0.12/robo_appian/components/LabelUtils.py +46 -0
  8. {robo_appian-0.0.10 → robo_appian-0.0.12}/robo_appian/components/LinkUtils.py +9 -9
  9. robo_appian-0.0.12/robo_appian/components/SearchDropdownUtils.py +75 -0
  10. {robo_appian-0.0.10 → robo_appian-0.0.12}/robo_appian/components/SearchInputUtils.py +23 -28
  11. {robo_appian-0.0.10 → robo_appian-0.0.12}/robo_appian/components/TabUtils.py +24 -29
  12. robo_appian-0.0.12/robo_appian/components/TableUtils.py +122 -0
  13. {robo_appian-0.0.10 → robo_appian-0.0.12}/robo_appian/controllers/ComponentDriver.py +7 -10
  14. {robo_appian-0.0.10 → robo_appian-0.0.12}/robo_appian/utils/ComponentUtils.py +6 -3
  15. robo_appian-0.0.10/robo_appian/components/ButtonUtils.py +0 -91
  16. robo_appian-0.0.10/robo_appian/components/DateUtils.py +0 -145
  17. robo_appian-0.0.10/robo_appian/components/DropdownUtils.py +0 -177
  18. robo_appian-0.0.10/robo_appian/components/InputUtils.py +0 -129
  19. robo_appian-0.0.10/robo_appian/components/LabelUtils.py +0 -54
  20. robo_appian-0.0.10/robo_appian/components/TableUtils.py +0 -157
  21. {robo_appian-0.0.10 → robo_appian-0.0.12}/LICENSE +0 -0
  22. {robo_appian-0.0.10 → robo_appian-0.0.12}/README.md +0 -0
  23. {robo_appian-0.0.10 → robo_appian-0.0.12}/robo_appian/__init__.py +0 -0
  24. {robo_appian-0.0.10 → robo_appian-0.0.12}/robo_appian/components/__init__.py +0 -0
  25. {robo_appian-0.0.10 → robo_appian-0.0.12}/robo_appian/controllers/__init__.py +0 -0
  26. {robo_appian-0.0.10 → robo_appian-0.0.12}/robo_appian/exceptions/MyCustomError.py +0 -0
  27. {robo_appian-0.0.10 → robo_appian-0.0.12}/robo_appian/exceptions/__init__.py +0 -0
  28. {robo_appian-0.0.10 → robo_appian-0.0.12}/robo_appian/utils/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: robo_appian
3
- Version: 0.0.10
3
+ Version: 0.0.12
4
4
  Summary: Automate your Appian code testing with Python. Boost quality, save time.
5
5
  Author: Dinil Mithra
6
6
  Author-email: dinilmithra@mailme@gmail.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "robo_appian"
3
- version = "0.0.10"
3
+ version = "0.0.12"
4
4
  description = "Automate your Appian code testing with Python. Boost quality, save time."
5
5
  authors = ["Dinil Mithra <dinilmithra@mailme@gmail.com>"]
6
6
  readme = "README.md"
@@ -0,0 +1,69 @@
1
+ from selenium.webdriver.common.by import By
2
+ from selenium.webdriver.support import expected_conditions as EC
3
+ from selenium.webdriver.support.ui import WebDriverWait
4
+
5
+
6
+ class ButtonUtils:
7
+ """
8
+ Utility class for interacting with button components in Appian UI.
9
+ Usage Example:
10
+ # Click a button by its label
11
+ from robo_appian.components.ButtonUtils import ButtonUtils
12
+ ButtonUtils.clickByLabelText(wait, "Submit")
13
+ """
14
+
15
+ @staticmethod
16
+ def __findByLabelText(wait: WebDriverWait, label: str):
17
+ """
18
+ Finds a button by its label.
19
+
20
+ Parameters:
21
+ wait: Selenium WebDriverWait instance.
22
+ label: The label of the button to find.
23
+ label: The label of the button to find.
24
+
25
+ Returns:
26
+ WebElement representing the button.
27
+
28
+ Example:
29
+ component = ButtonUtils.__findByLabelText(wait, "Submit")
30
+ """
31
+ xpath = f".//button[./span[contains(translate(normalize-space(.), '\u00a0', ' '), '{label}')]]"
32
+ try:
33
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
34
+ except Exception as e:
35
+ raise RuntimeError(f"Button with label '{label}' not found or not clickable.") from e
36
+ return component
37
+
38
+ @staticmethod
39
+ def clickByLabelText(wait: WebDriverWait, label: str):
40
+ """Finds a button by its label and clicks it.
41
+
42
+ Parameters:
43
+ wait: Selenium WebDriverWait instance.
44
+ label: The label of the button to click.
45
+ Example:
46
+ ButtonUtils.clickByLabelText(wait, "Button Label")
47
+ """
48
+ component = ButtonUtils.__findByLabelText(wait, label)
49
+ component.click()
50
+
51
+ @staticmethod
52
+ def clickById(wait: WebDriverWait, id: str):
53
+ """
54
+ Finds and clicks an input button by its HTML id attribute.
55
+
56
+ Parameters:
57
+ wait: Selenium WebDriverWait instance.
58
+ id: The HTML id of the input button.
59
+
60
+ Example:
61
+ ButtonUtils.clickById(wait, "button_id")
62
+
63
+ """
64
+ try:
65
+ component = wait.until(EC.element_to_be_clickable((By.ID, id)))
66
+ except Exception as e:
67
+ raise RuntimeError(f"Input button with id '{id}' not found or not clickable.") from e
68
+
69
+ component.click()
@@ -0,0 +1,77 @@
1
+ from selenium.webdriver.common.by import By
2
+ from selenium.webdriver.support import expected_conditions as EC
3
+ from selenium.webdriver.support.ui import WebDriverWait
4
+
5
+ from robo_appian.components.InputUtils import InputUtils
6
+
7
+
8
+ class DateUtils:
9
+ """
10
+ Utility class for interacting with date components in Appian UI.
11
+ Usage Example:
12
+ # Set a date value in a date component
13
+ from robo_appian.components.DateUtils import DateUtils
14
+ DateUtils.setValueByLabelText(wait, "Start Date", "2023-10-01")
15
+ """
16
+
17
+ @staticmethod
18
+ def __findComponent(wait: WebDriverWait, label: str):
19
+ """
20
+ Finds a date component by its label.
21
+ :param wait: WebDriverWait instance to wait for elements.
22
+ :param label: The label of the date component.
23
+ :return: The WebElement representing the date component.
24
+ Example:
25
+ DateUtils.__findComponent(wait, "Start Date")
26
+ """
27
+ # xpath = f".//div/label[text()='{label}']"
28
+ # try:
29
+ # component: WebElement = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
30
+ # except Exception as e:
31
+ # raise Exception(f"Could not find clickable date component with label '{label}': {e}")
32
+
33
+ # attribute: str = "for"
34
+ # component_id = component.get_attribute(attribute) # type: ignore[reportUnknownMemberType]
35
+ # if component_id is None:
36
+ # raise ValueError(f"Could not find component using {attribute} attribute for label '{label}'.")
37
+
38
+ # try:
39
+ # component = wait.until(EC.element_to_be_clickable((By.ID, component_id)))
40
+ # except Exception as e:
41
+ # raise Exception(f"Could not find clickable date input with id '{component_id}': {e}")
42
+
43
+ xpath = f'.//div[./div/label[text()="{label}"]]/div/div/div/input'
44
+ try:
45
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
46
+ except Exception as e:
47
+ raise Exception(f"Could not find clickable date component with label '{label}': {e}")
48
+ return component
49
+
50
+ @staticmethod
51
+ def setValueByLabelText(wait: WebDriverWait, label: str, value: str):
52
+ """
53
+ Sets the value of a date component.
54
+ :param wait: WebDriverWait instance to wait for elements.
55
+ :param label: The label of the date component.
56
+ :param value: The value to set in the date component.
57
+ :return: The WebElement representing the date component.
58
+ Example:
59
+ DateUtils.setValueByLabelText(wait, "Start Date", "2023-10-01")
60
+ """
61
+ component = DateUtils.__findComponent(wait, label)
62
+ InputUtils._setValueByComponent(component, value)
63
+ return component
64
+
65
+ @staticmethod
66
+ def clickByLabelText(wait: WebDriverWait, label: str):
67
+ """
68
+ Clicks on the date component to open the date picker.
69
+ :param wait: WebDriverWait instance to wait for elements.
70
+ :param label: The label of the date component.
71
+ :return: The WebElement representing the date component.
72
+ Example:
73
+ DateUtils.clickByLabelText(wait, "Start Date")
74
+ """
75
+ component = DateUtils.__findComponent(wait, label)
76
+ component.click()
77
+ return component
@@ -0,0 +1,244 @@
1
+ from selenium.webdriver.common.by import By
2
+ from selenium.webdriver.support import expected_conditions as EC
3
+ from selenium.webdriver.support.ui import WebDriverWait
4
+ from selenium.webdriver.remote.webelement import WebElement
5
+ from selenium.common.exceptions import NoSuchElementException
6
+
7
+
8
+ class DropdownUtils:
9
+ """
10
+ Utility class for interacting with dropdown components in Appian UI.
11
+ Usage Example:
12
+ # Select a value from a dropdown
13
+ from robo_appian.components.DropdownUtils import DropdownUtils
14
+ DropdownUtils.selectDropdownValueByLabelText(wait, "Status", "Approved")
15
+ """
16
+
17
+ @staticmethod
18
+ def __findComboboxByPartialLabelText(wait: WebDriverWait, label: str):
19
+ """
20
+ Finds a combobox by its partial label text.
21
+
22
+ :param wait: Selenium WebDriverWait instance.
23
+ :param label: The partial label of the combobox to find.
24
+ :return: WebElement representing the combobox.
25
+ Example:
26
+ component = DropdownUtils.__findComboboxByPartialLabelText(wait, "Dropdown Label")
27
+ """
28
+ xpath = f'.//div[./div/span[contains(normalize-space(text()), "{label}")]]/div/div/div/div[@role="combobox" and not(@aria-disabled="true")]' # noqa: E501
29
+ try:
30
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
31
+ except Exception as e:
32
+ raise Exception(f'Could not find combobox with partial label "{label}" : {str(e)}')
33
+
34
+ return component
35
+
36
+ @staticmethod
37
+ def __findComboboxByLabelText(wait: WebDriverWait, label: str):
38
+ """
39
+ Finds a combobox by its label text.
40
+
41
+ :param wait: Selenium WebDriverWait instance.
42
+ :param label: The label of the combobox to find.
43
+ :return: WebElement representing the combobox.
44
+ Example:
45
+ component = DropdownUtils.__findComboboxByLabelText(wait, "Dropdown Label")
46
+ """
47
+ xpath = f'.//div[./div/span[normalize-space(text())="{label}"]]/div/div/div/div[@role="combobox" and not(@aria-disabled="true")]' # noqa: E501
48
+ try:
49
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
50
+ except Exception as e:
51
+ raise Exception(f'Could not find combobox with label "{label}" : {str(e)}')
52
+
53
+ return component
54
+
55
+ @staticmethod
56
+ def __clickCombobox(wait: WebDriverWait, combobox: WebElement):
57
+ """
58
+ Clicks the combobox to open the dropdown options.
59
+
60
+ :param wait: WebDriverWait instance to wait for elements.
61
+ :param combobox: The combobox WebElement.
62
+ Example:
63
+ DropdownUtils.__clickCombobox(wait, combobox)
64
+ """
65
+ combobox.click()
66
+
67
+ @staticmethod
68
+ def __findDropdownOptionId(wait: WebDriverWait, combobox: WebElement):
69
+ """
70
+ Finds the dropdown option id from the combobox.
71
+
72
+ :param wait: WebDriverWait instance to wait for elements.
73
+ :param combobox: The combobox WebElement.
74
+ :return: The id of the dropdown options list.
75
+ Example:
76
+ dropdown_option_id = DropdownUtils.__findDropdownOptionId(wait, combobox)
77
+ """
78
+ dropdown_option_id = combobox.get_attribute("aria-controls")
79
+ if dropdown_option_id is None:
80
+ raise Exception('Dropdown component does not have a valid "aria-controls" attribute.')
81
+ return dropdown_option_id
82
+
83
+ @staticmethod
84
+ def __checkDropdownOptionValueExistsByDropdownOptionId(wait: WebDriverWait, dropdown_option_id: str, value: str):
85
+ """
86
+ Checks if a dropdown option value exists by its option id and value.
87
+
88
+ :param wait: WebDriverWait instance to wait for elements.
89
+ :param dropdown_option_id: The id of the dropdown options list.
90
+ :param value: The value to check in the dropdown.
91
+ Example:
92
+ exists = DropdownUtils.checkDropdownOptionValueExistsByDropdownOptionId(wait, "dropdown_option_id", "Option Value")
93
+ if exists:
94
+ print("The value exists in the dropdown.")
95
+ else:
96
+ print("The value does not exist in the dropdown.")
97
+ """
98
+
99
+ xpath = f'.//div/ul[@id="{dropdown_option_id}"]/li[./div[normalize-space(text())="{value}"]]'
100
+ try:
101
+ wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
102
+ return True
103
+ except NoSuchElementException:
104
+ return False
105
+ except Exception as e:
106
+ raise Exception(f'Could not find dropdown option "{value}" with dropdown option id "{dropdown_option_id}": {str(e)}')
107
+
108
+ @staticmethod
109
+ def __selectDropdownValueByDropdownOptionId(wait: WebDriverWait, dropdown_option_id: str, value: str):
110
+ """
111
+ Selects a value from a dropdown by its option id and value.
112
+
113
+ :param wait: WebDriverWait instance to wait for elements.
114
+ :param dropdown_option_id: The id of the dropdown options list.
115
+ :param value: The value to select from the dropdown.
116
+ Example:
117
+ DropdownUtils.selectDropdownValueByDropdownOptionId(wait, "dropdown_option_id", "Option Value")
118
+ """
119
+ option_xpath = f'.//div/ul[@id="{dropdown_option_id}"]/li[./div[normalize-space(text())="{value}"]]'
120
+ try:
121
+ try:
122
+ component = wait.until(EC.presence_of_element_located((By.XPATH, option_xpath)))
123
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, option_xpath)))
124
+ except Exception as e:
125
+ raise Exception(
126
+ f'Could not locate or click dropdown option "{value}" with dropdown option id "{dropdown_option_id}": {str(e)}' # noqa: E501
127
+ )
128
+ except Exception as e:
129
+ raise Exception(f'Could not find or click dropdown option "{value}" with xpath "{option_xpath}": {str(e)}')
130
+ component.click()
131
+
132
+ @staticmethod
133
+ def __selectDropdownValueByPartialLabelText(wait: WebDriverWait, label: str, value: str):
134
+ """
135
+ Selects a value from a dropdown by its label text.
136
+
137
+ :param wait: WebDriverWait instance to wait for elements.
138
+ :param label: The label of the dropdown.
139
+ :param value: The value to select from the dropdown.
140
+ """
141
+ combobox = DropdownUtils.__findComboboxByPartialLabelText(wait, label)
142
+ DropdownUtils.__clickCombobox(wait, combobox)
143
+ dropdown_option_id = DropdownUtils.__findDropdownOptionId(wait, combobox)
144
+ DropdownUtils.__selectDropdownValueByDropdownOptionId(wait, dropdown_option_id, value)
145
+
146
+ @staticmethod
147
+ def __selectDropdownValueByLabelText(wait: WebDriverWait, label: str, value: str):
148
+ """
149
+ Selects a value from a dropdown by its label text.
150
+
151
+ :param wait: WebDriverWait instance to wait for elements.
152
+ :param label: The label of the dropdown.
153
+ :param value: The value to select from the dropdown.
154
+ """
155
+ combobox = DropdownUtils.__findComboboxByLabelText(wait, label)
156
+ DropdownUtils.__clickCombobox(wait, combobox)
157
+ dropdown_option_id = DropdownUtils.__findDropdownOptionId(wait, combobox)
158
+ DropdownUtils.__selectDropdownValueByDropdownOptionId(wait, dropdown_option_id, value)
159
+
160
+ @staticmethod
161
+ def checkReadOnlyStatusByLabelText(wait: WebDriverWait, label: str):
162
+ """
163
+ Checks if a dropdown is read-only by its label text.
164
+
165
+ :param wait: WebDriverWait instance to wait for elements.
166
+ :param label: The label of the dropdown.
167
+ :return: True if the dropdown is read-only, False otherwise.
168
+ Example:
169
+ is_read_only = DropdownUtils.checkReadOnlyStatusByLabelText(wait, "Dropdown Label")
170
+ if is_read_only:
171
+ print("The dropdown is read-only.")
172
+ else:
173
+ print("The dropdown is editable.")
174
+ """
175
+ xpath = f'.//div[./div/span[normalize-space(text())="{label}"]]/div/div/p[text()]'
176
+ try:
177
+ wait._driver.find_element(By.XPATH, xpath)
178
+ return True
179
+ except NoSuchElementException:
180
+ return False
181
+ except Exception:
182
+ raise Exception(f'Error checking read-only status for label "{label}"')
183
+
184
+ @staticmethod
185
+ def selectDropdownValueByComboboxComponent(wait: WebDriverWait, combobox: WebElement, value: str):
186
+ """
187
+ Selects a value from a dropdown using the combobox component.
188
+
189
+ :param wait: WebDriverWait instance to wait for elements.
190
+ :param combobox: The combobox WebElement.
191
+ :param value: The value to select from the dropdown.
192
+ Example:
193
+ DropdownUtils.selectDropdownValueByComboboxComponent(wait, combobox, "Option Value")
194
+ """
195
+ dropdown_option_id = DropdownUtils.__findDropdownOptionId(wait, combobox)
196
+ DropdownUtils.__clickCombobox(wait, combobox)
197
+ DropdownUtils.__selectDropdownValueByDropdownOptionId(wait, dropdown_option_id, value)
198
+
199
+ @staticmethod
200
+ def selectDropdownValueByLabelText(wait: WebDriverWait, dropdown_label: str, value: str):
201
+ """
202
+ Selects a value from a dropdown by its label text.
203
+
204
+ :param wait: WebDriverWait instance to wait for elements.
205
+ :param dropdown_label: The label of the dropdown.
206
+ :param value: The value to select from the dropdown.
207
+ Example:
208
+ DropdownUtils.selectDropdownValueByLabelText(wait, "Dropdown Label", "Option Value")
209
+ """
210
+ DropdownUtils.__selectDropdownValueByLabelText(wait, dropdown_label, value)
211
+
212
+ @staticmethod
213
+ def selectDropdownValueByPartialLabelText(wait: WebDriverWait, dropdown_label: str, value: str):
214
+ """
215
+ Selects a value from a dropdown by its partial label text.
216
+
217
+ :param wait: WebDriverWait instance to wait for elements.
218
+ :param dropdown_label: The partial label of the dropdown.
219
+ :param value: The value to select from the dropdown.
220
+ Example:
221
+ DropdownUtils.selectDropdownValueByPartialLabelText(wait, "Dropdown Label", "Option Value")
222
+ """
223
+ DropdownUtils.__selectDropdownValueByPartialLabelText(wait, dropdown_label, value)
224
+
225
+ @staticmethod
226
+ def checkDropdownOptionValueExists(wait: WebDriverWait, dropdown_label: str, value: str):
227
+ """
228
+ Checks if a dropdown option value exists by its label text.
229
+
230
+ :param wait: WebDriverWait instance to wait for elements.
231
+ :param dropdown_label: The label of the dropdown.
232
+ :param value: The value to check in the dropdown.
233
+ :return: True if the value exists, False otherwise.
234
+ Example:
235
+ exists = DropdownUtils.checkDropdownOptionValueExists(wait, "Dropdown Label", "Option Value")
236
+ if exists:
237
+ print("The value exists in the dropdown.")
238
+ else:
239
+ print("The value does not exist in the dropdown.")
240
+ """
241
+ combobox = DropdownUtils.__findComboboxByLabelText(wait, dropdown_label)
242
+ DropdownUtils.__clickCombobox(wait, combobox)
243
+ dropdown_option_id = DropdownUtils.__findDropdownOptionId(wait, combobox)
244
+ return DropdownUtils.__checkDropdownOptionValueExistsByDropdownOptionId(wait, dropdown_option_id, value)
@@ -0,0 +1,165 @@
1
+ from robo_appian.utils.ComponentUtils import ComponentUtils
2
+ from selenium.webdriver.common.by import By
3
+ from selenium.webdriver.support import expected_conditions as EC
4
+ from selenium.webdriver.support.ui import WebDriverWait
5
+ from selenium.webdriver.remote.webelement import WebElement
6
+
7
+
8
+ class InputUtils:
9
+ """
10
+ Utility class for interacting with input components in Appian UI.
11
+ Usage Example:
12
+ from robo_appian.components.InputUtils import InputUtils
13
+
14
+ # Set a value in an input component by its label
15
+ InputUtils.setValueByLabelText(wait, "Username", "test_user")
16
+
17
+ # Set a value in an input component by its ID
18
+ InputUtils.setValueById(wait, "inputComponentId", "test_value")
19
+ """
20
+
21
+ @staticmethod
22
+ def __findInputComponentsByXpath(wait: WebDriverWait, xpath: str):
23
+ """
24
+ Finds input components by their XPath.
25
+
26
+ Parameters:
27
+ wait: Selenium WebDriverWait instance.
28
+ xpath: The XPath expression to locate the input components.
29
+
30
+ Returns:
31
+ A list of Selenium WebElement representing the input components.
32
+
33
+ Example:
34
+ InputUtils.__findInputComponentsByXpath(wait, './/div/label[normalize-space(text())="Username"]')
35
+ """
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
+
55
+ Parameters:
56
+ wait: Selenium WebDriverWait instance.
57
+ label: The visible text label of the input component, allowing for partial matches.
58
+
59
+ Returns:
60
+ A list of Selenium WebElement representing the input components.
61
+
62
+ Example:
63
+ InputUtils.__findInputComponentsByPartialLabel(wait, "Username")
64
+ """
65
+ xpath = f'.//div/label[contains(normalize-space(text()), "{label}")]'
66
+ components = InputUtils.__findInputComponentsByXpath(wait, xpath)
67
+ return components
68
+
69
+ @staticmethod
70
+ def __findComponentsByLabel(wait: WebDriverWait, label: str):
71
+ """Finds input components by their label text.
72
+
73
+ Parameters:
74
+ wait: Selenium WebDriverWait instance.
75
+ label: The visible text label of the input component.
76
+
77
+ Returns:
78
+ A list of Selenium WebElement representing the input components.
79
+
80
+ Example:
81
+ InputUtils.__findComponentsByLabel(wait, "Username")
82
+ """
83
+ xpath = f'.//div/label[normalize-space(text())="{label}"]'
84
+ components = InputUtils.__findInputComponentsByXpath(wait, xpath)
85
+ return components
86
+
87
+ @staticmethod
88
+ def _setValueByComponent(component: WebElement, value: str):
89
+ """
90
+ Sets a value in an input component.
91
+ Parameters:
92
+ component: The Selenium WebElement for the input component.
93
+ value: The value to set in the input field.
94
+ Returns:
95
+ The Selenium WebElement for the input component after setting the value.
96
+ Example:
97
+ InputUtils._setValueByComponent(component, "test_value")
98
+ """
99
+ component.clear()
100
+ component.send_keys(value)
101
+ return component
102
+
103
+ @staticmethod
104
+ def __setValueByComponents(wait: WebDriverWait, input_components, value: str):
105
+ """
106
+ Sets a value in an input component identified by its label text.
107
+ Parameters:
108
+ wait: Selenium WebDriverWait instance.
109
+ label: The visible text label of the input component.
110
+ value: The value to set in the input field.
111
+ Returns:
112
+ None
113
+ Example:
114
+ InputUtils.setValueByLabelText(wait, "Username", "test_user")
115
+ """
116
+
117
+ for component in input_components:
118
+ InputUtils._setValueByComponent(component, value)
119
+
120
+ @staticmethod
121
+ def setValueByPartialLabelText(wait: WebDriverWait, label: str, value: str):
122
+ input_components = InputUtils.__findInputComponentsByPartialLabel(wait, label)
123
+ InputUtils.__setValueByComponents(wait, input_components, value)
124
+
125
+ @staticmethod
126
+ def setValueByLabelText(wait: WebDriverWait, label: str, value: str):
127
+ """
128
+ Sets a value in an input component identified by its label text.
129
+
130
+ Parameters:
131
+ wait: Selenium WebDriverWait instance.
132
+ label: The visible text label of the input component.
133
+ value: The value to set in the input field.
134
+
135
+ Returns:
136
+ None
137
+
138
+ Example:
139
+ InputUtils.setValueByLabelText(wait, "Username", "test_user")
140
+ """
141
+ input_components = InputUtils.__findComponentsByLabel(wait, label)
142
+ InputUtils.__setValueByComponents(wait, input_components, value)
143
+
144
+ @staticmethod
145
+ def setValueById(wait: WebDriverWait, component_id: str, value: str):
146
+ """
147
+ Sets a value in an input component identified by its ID.
148
+
149
+ Parameters:
150
+ wait: Selenium WebDriverWait instance.
151
+ component_id: The ID of the input component.
152
+ value: The value to set in the input field.
153
+
154
+ Returns:
155
+ The Selenium WebElement for the input component after setting the value.
156
+
157
+ Example:
158
+ InputUtils.setValueById(wait, "inputComponentId", "test_value")
159
+ """
160
+ try:
161
+ component = wait.until(EC.element_to_be_clickable((By.ID, component_id)))
162
+ except Exception as e:
163
+ raise Exception(f"Timeout or error finding input component with id '{component_id}': {e}")
164
+ InputUtils._setValueByComponent(component, value)
165
+ return component
@@ -0,0 +1,46 @@
1
+ from selenium.webdriver.common.by import By
2
+ from selenium.webdriver.support import expected_conditions as EC
3
+ from selenium.webdriver.support.ui import WebDriverWait
4
+
5
+
6
+ class LabelUtils:
7
+ """
8
+ Utility class for interacting with label components in Appian UI.
9
+ Usage Example:
10
+ # Find a label by its text
11
+ component = LabelUtils.findByLabelText(wait, "Submit")
12
+ # Click a label by its text
13
+ LabelUtils.clickByLabelText(wait, "Submit")
14
+ """
15
+
16
+ @staticmethod
17
+ def findByLabelText(wait: WebDriverWait, label: str):
18
+ """
19
+ Finds a label element by its text.
20
+
21
+ :param wait: Selenium WebDriverWait instance.
22
+ :param label: The text of the label to find.
23
+ :return: WebElement representing the label.
24
+ Example:
25
+ component = LabelUtils.findByLabelText(wait, "Submit")
26
+ """
27
+ xpath = f".//*[normalize-space(text())='{label}']"
28
+ try:
29
+ component = wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
30
+ except Exception as e:
31
+ raise RuntimeError(f"Label with text '{label}' not found.") from e
32
+
33
+ return component
34
+
35
+ @staticmethod
36
+ def clickByLabelText(wait: WebDriverWait, label: str):
37
+ """
38
+ Clicks a label element identified by its text.
39
+
40
+ :param wait: Selenium WebDriverWait instance.
41
+ :param label: The text of the label to click.
42
+ Example:
43
+ LabelUtils.clickByLabelText(wait, "Submit")
44
+ """
45
+ component = LabelUtils.findByLabelText(wait, label)
46
+ component.click()
@@ -5,14 +5,16 @@ from selenium.webdriver.support.ui import WebDriverWait
5
5
 
6
6
  class LinkUtils:
7
7
  """
8
- Utility class for interacting with link components in Appian UI.
9
-
10
- Usage Example:
11
-
12
- # Click a link with a specific label
8
+ Utility class for handling link operations in Selenium WebDriver.
9
+ Example usage:
10
+ from selenium import webdriver
11
+ from selenium.webdriver.support.ui import WebDriverWait
13
12
  from robo_appian.components.LinkUtils import LinkUtils
14
- LinkUtils.click(wait, "Learn More")
15
13
 
14
+ driver = webdriver.Chrome()
15
+ wait = WebDriverWait(driver, 10)
16
+ LinkUtils.click(wait, "Learn More")
17
+ driver.quit()
16
18
  """
17
19
 
18
20
  @staticmethod
@@ -21,9 +23,7 @@ class LinkUtils:
21
23
  try:
22
24
  component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
23
25
  except TimeoutError as e:
24
- raise TimeoutError(
25
- f"Could not find clickable link with label '{label}': {e}"
26
- )
26
+ raise TimeoutError(f"Could not find clickable link with label '{label}': {e}")
27
27
  except Exception as e:
28
28
  raise Exception(f"Could not find clickable link with label '{label}': {e}")
29
29
  return component