robo_appian 0.0.11__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 (26) hide show
  1. {robo_appian-0.0.11 → robo_appian-0.0.12}/PKG-INFO +1 -1
  2. {robo_appian-0.0.11 → robo_appian-0.0.12}/pyproject.toml +1 -1
  3. {robo_appian-0.0.11 → robo_appian-0.0.12}/robo_appian/components/ButtonUtils.py +31 -13
  4. robo_appian-0.0.12/robo_appian/components/DateUtils.py +77 -0
  5. {robo_appian-0.0.11 → robo_appian-0.0.12}/robo_appian/components/DropdownUtils.py +117 -5
  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.11 → robo_appian-0.0.12}/robo_appian/components/LinkUtils.py +9 -9
  9. {robo_appian-0.0.11 → robo_appian-0.0.12}/robo_appian/components/SearchDropdownUtils.py +1 -1
  10. {robo_appian-0.0.11 → robo_appian-0.0.12}/robo_appian/components/SearchInputUtils.py +23 -28
  11. {robo_appian-0.0.11 → 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.11 → robo_appian-0.0.12}/robo_appian/controllers/ComponentDriver.py +4 -4
  14. robo_appian-0.0.11/robo_appian/components/DateUtils.py +0 -145
  15. robo_appian-0.0.11/robo_appian/components/InputUtils.py +0 -129
  16. robo_appian-0.0.11/robo_appian/components/LabelUtils.py +0 -54
  17. robo_appian-0.0.11/robo_appian/components/TableUtils.py +0 -157
  18. {robo_appian-0.0.11 → robo_appian-0.0.12}/LICENSE +0 -0
  19. {robo_appian-0.0.11 → robo_appian-0.0.12}/README.md +0 -0
  20. {robo_appian-0.0.11 → robo_appian-0.0.12}/robo_appian/__init__.py +0 -0
  21. {robo_appian-0.0.11 → robo_appian-0.0.12}/robo_appian/components/__init__.py +0 -0
  22. {robo_appian-0.0.11 → robo_appian-0.0.12}/robo_appian/controllers/__init__.py +0 -0
  23. {robo_appian-0.0.11 → robo_appian-0.0.12}/robo_appian/exceptions/MyCustomError.py +0 -0
  24. {robo_appian-0.0.11 → robo_appian-0.0.12}/robo_appian/exceptions/__init__.py +0 -0
  25. {robo_appian-0.0.11 → robo_appian-0.0.12}/robo_appian/utils/ComponentUtils.py +0 -0
  26. {robo_appian-0.0.11 → 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.11
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.11"
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"
@@ -4,8 +4,30 @@ from selenium.webdriver.support.ui import WebDriverWait
4
4
 
5
5
 
6
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
+
7
15
  @staticmethod
8
- def find(wait: WebDriverWait, label: str):
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
+ """
9
31
  xpath = f".//button[./span[contains(translate(normalize-space(.), '\u00a0', ' '), '{label}')]]"
10
32
  try:
11
33
  component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
@@ -14,22 +36,20 @@ class ButtonUtils:
14
36
  return component
15
37
 
16
38
  @staticmethod
17
- def click(wait: WebDriverWait, label: str):
18
- """
19
- Clicks a button identified by its label.
39
+ def clickByLabelText(wait: WebDriverWait, label: str):
40
+ """Finds a button by its label and clicks it.
20
41
 
21
42
  Parameters:
22
43
  wait: Selenium WebDriverWait instance.
23
- label: The visible text label of the button.
24
- Example:
25
- ButtonUtils.click(wait, "Submit")
26
-
44
+ label: The label of the button to click.
45
+ Example:
46
+ ButtonUtils.clickByLabelText(wait, "Button Label")
27
47
  """
28
- component = ButtonUtils.find(wait, label)
48
+ component = ButtonUtils.__findByLabelText(wait, label)
29
49
  component.click()
30
50
 
31
51
  @staticmethod
32
- def clickInputButtonById(wait: WebDriverWait, id: str):
52
+ def clickById(wait: WebDriverWait, id: str):
33
53
  """
34
54
  Finds and clicks an input button by its HTML id attribute.
35
55
 
@@ -38,13 +58,11 @@ class ButtonUtils:
38
58
  id: The HTML id of the input button.
39
59
 
40
60
  Example:
41
- ButtonUtils.clickInputButtonById(wait, "button_id")
61
+ ButtonUtils.clickById(wait, "button_id")
42
62
 
43
63
  """
44
64
  try:
45
65
  component = wait.until(EC.element_to_be_clickable((By.ID, id)))
46
- except TimeoutError as e:
47
- raise TimeoutError(f"Input button with id '{id}' not found or not clickable.") from e
48
66
  except Exception as e:
49
67
  raise RuntimeError(f"Input button with id '{id}' not found or not clickable.") from e
50
68
 
@@ -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
@@ -16,7 +16,16 @@ class DropdownUtils:
16
16
 
17
17
  @staticmethod
18
18
  def __findComboboxByPartialLabelText(wait: WebDriverWait, label: str):
19
- xpath = f'.//div[./div/span[contains(normalize-space(text()), "{label}")]]/div/div/div/div[@role="combobox" and not(@aria-disabled="true")]'
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
20
29
  try:
21
30
  component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
22
31
  except Exception as e:
@@ -26,7 +35,16 @@ class DropdownUtils:
26
35
 
27
36
  @staticmethod
28
37
  def __findComboboxByLabelText(wait: WebDriverWait, label: str):
29
- xpath = f'.//div[./div/span[normalize-space(text())="{label}"]]/div/div/div/div[@role="combobox" and not(@aria-disabled="true")]'
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
30
48
  try:
31
49
  component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
32
50
  except Exception as e:
@@ -36,10 +54,27 @@ class DropdownUtils:
36
54
 
37
55
  @staticmethod
38
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
+ """
39
65
  combobox.click()
40
66
 
41
67
  @staticmethod
42
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
+ """
43
78
  dropdown_option_id = combobox.get_attribute("aria-controls")
44
79
  if dropdown_option_id is None:
45
80
  raise Exception('Dropdown component does not have a valid "aria-controls" attribute.')
@@ -47,9 +82,23 @@ class DropdownUtils:
47
82
 
48
83
  @staticmethod
49
84
  def __checkDropdownOptionValueExistsByDropdownOptionId(wait: WebDriverWait, dropdown_option_id: str, value: str):
50
- option_xpath = f'.//div/ul[@id="{dropdown_option_id}"]/li[./div[normalize-space(text())="{value}"]]'
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}"]]'
51
100
  try:
52
- wait.until(EC.element_to_be_clickable((By.XPATH, option_xpath)))
101
+ wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
53
102
  return True
54
103
  except NoSuchElementException:
55
104
  return False
@@ -58,6 +107,15 @@ class DropdownUtils:
58
107
 
59
108
  @staticmethod
60
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
+ """
61
119
  option_xpath = f'.//div/ul[@id="{dropdown_option_id}"]/li[./div[normalize-space(text())="{value}"]]'
62
120
  try:
63
121
  try:
@@ -65,7 +123,7 @@ class DropdownUtils:
65
123
  component = wait.until(EC.element_to_be_clickable((By.XPATH, option_xpath)))
66
124
  except Exception as e:
67
125
  raise Exception(
68
- f'Could not locate or click dropdown option "{value}" with dropdown option id "{dropdown_option_id}": {str(e)}'
126
+ f'Could not locate or click dropdown option "{value}" with dropdown option id "{dropdown_option_id}": {str(e)}' # noqa: E501
69
127
  )
70
128
  except Exception as e:
71
129
  raise Exception(f'Could not find or click dropdown option "{value}" with xpath "{option_xpath}": {str(e)}')
@@ -101,6 +159,19 @@ class DropdownUtils:
101
159
 
102
160
  @staticmethod
103
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
+ """
104
175
  xpath = f'.//div[./div/span[normalize-space(text())="{label}"]]/div/div/p[text()]'
105
176
  try:
106
177
  wait._driver.find_element(By.XPATH, xpath)
@@ -112,20 +183,61 @@ class DropdownUtils:
112
183
 
113
184
  @staticmethod
114
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
+ """
115
195
  dropdown_option_id = DropdownUtils.__findDropdownOptionId(wait, combobox)
116
196
  DropdownUtils.__clickCombobox(wait, combobox)
117
197
  DropdownUtils.__selectDropdownValueByDropdownOptionId(wait, dropdown_option_id, value)
118
198
 
119
199
  @staticmethod
120
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
+ """
121
210
  DropdownUtils.__selectDropdownValueByLabelText(wait, dropdown_label, value)
122
211
 
123
212
  @staticmethod
124
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
+ """
125
223
  DropdownUtils.__selectDropdownValueByPartialLabelText(wait, dropdown_label, value)
126
224
 
127
225
  @staticmethod
128
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
+ """
129
241
  combobox = DropdownUtils.__findComboboxByLabelText(wait, dropdown_label)
130
242
  DropdownUtils.__clickCombobox(wait, combobox)
131
243
  dropdown_option_id = DropdownUtils.__findDropdownOptionId(wait, combobox)
@@ -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
@@ -20,7 +20,7 @@ class SearchDropdownUtils:
20
20
  input_component = wait.until(EC.element_to_be_clickable((By.ID, input_component_id)))
21
21
  except Exception as e:
22
22
  raise RuntimeError(f"Failed to locate or click input component with ID '{input_component_id}': {e}")
23
- InputUtils._setComponentValue(input_component, value)
23
+ InputUtils._setValueByComponent(input_component, value)
24
24
 
25
25
  xpath = f'.//ul[@id="{dropdown_option_id}"]/li[./div[normalize-space(text())="{value}"]][1]'
26
26
  try: