robo_appian 0.0.2__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.

@@ -0,0 +1,11 @@
1
+ from robo_appian.utils.components.ButtonUtils import ButtonUtils
2
+ from robo_appian.utils.components.ComponentUtils import ComponentUtils
3
+ from robo_appian.utils.components.DateUtils import DateUtils
4
+ from robo_appian.utils.components.DropdownUtils import DropdownUtils
5
+ from robo_appian.utils.components.InputUtils import InputUtils
6
+ from robo_appian.utils.components.LabelUtils import LabelUtils
7
+ from robo_appian.utils.components.LinkUtils import LinkUtils
8
+ from robo_appian.utils.components.TableUtils import TableUtils
9
+ from robo_appian.utils.components.TabUtils import TabUtils
10
+
11
+ __version__ = "0.1.0"
File without changes
@@ -0,0 +1,72 @@
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.webdriver import WebDriver
5
+
6
+ class ButtonUtils:
7
+ """
8
+ Utility class for interacting with button elements in Selenium-based Appian UI automation.
9
+
10
+ Usage Example:
11
+
12
+ from selenium.webdriver.support.ui import WebDriverWait
13
+ from robo_appian.utils.components.ButtonUtils import ButtonUtils
14
+
15
+ wait = WebDriverWait(driver, 10)
16
+ ButtonUtils.click(wait, "Login")
17
+
18
+ """
19
+
20
+ @staticmethod
21
+ def find(wait: WebDriverWait, label: str):
22
+ """
23
+ Finds a button element by its label.
24
+
25
+ Parameters:
26
+ wait: Selenium WebDriverWait instance.
27
+ label: The visible text label of the button.
28
+
29
+ Returns:
30
+ The Selenium WebElement for the button.
31
+
32
+ Example:
33
+ ButtonUtils.find(wait, "Submit")
34
+
35
+ """
36
+
37
+ # This method locates a button that contains a span with the specified label text.
38
+
39
+ xpath = f".//button[./span[contains(translate(normalize-space(.), '\u00a0', ' '), '{label}')]]"
40
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
41
+ return component
42
+
43
+ @staticmethod
44
+ def click(wait: WebDriverWait, label: str):
45
+ """
46
+ Clicks a button identified by its label.
47
+
48
+ Parameters:
49
+ wait: Selenium WebDriverWait instance.
50
+ label: The visible text label of the button.
51
+ Example:
52
+ ButtonUtils.click(wait, "Submit")
53
+
54
+ """
55
+ component = ButtonUtils.find(wait, label)
56
+ component.click()
57
+ @staticmethod
58
+ def clickInputButtonById(wait: WebDriverWait, id: str):
59
+ """
60
+ Finds and clicks an input button by its HTML id attribute.
61
+
62
+ Parameters:
63
+ wait: Selenium WebDriverWait instance.
64
+ id: The HTML id of the input button.
65
+
66
+ Example:
67
+ ButtonUtils.clickInputButtonById(wait, "button_id")
68
+
69
+ """
70
+ component = wait.until(EC.element_to_be_clickable((By.ID, id)))
71
+ component.click()
72
+ component.click()
@@ -0,0 +1,289 @@
1
+ from selenium.common.exceptions import NoSuchElementException
2
+ from selenium.webdriver import ActionChains
3
+ from selenium.webdriver.common.by import By
4
+ from selenium.webdriver.common.keys import Keys
5
+ from selenium.webdriver.support import expected_conditions as EC
6
+ from selenium.webdriver.remote.webdriver import WebDriver
7
+ from selenium.webdriver.support.ui import WebDriverWait
8
+
9
+
10
+ class ComponentUtils:
11
+ """
12
+ Utility class for interacting with various components in Appian UI.
13
+
14
+ """
15
+
16
+ @staticmethod
17
+ def today():
18
+ """
19
+ Returns today's date formatted as MM/DD/YYYY.
20
+ """
21
+
22
+ from datetime import date
23
+
24
+ today = date.today()
25
+ yesterday_formatted = today.strftime("%m/%d/%Y")
26
+ return yesterday_formatted
27
+
28
+ @staticmethod
29
+ def yesterday():
30
+ """
31
+ Returns yesterday's date formatted as MM/DD/YYYY.
32
+ """
33
+
34
+ from datetime import date, timedelta
35
+
36
+ yesterday = date.today() - timedelta(days=1)
37
+ yesterday_formatted = yesterday.strftime("%m/%d/%Y")
38
+ return yesterday_formatted
39
+
40
+ # @staticmethod
41
+ # def find_dropdown_id(wait, dropdown_label):
42
+ # label_class_name = "FieldLayout---field_label"
43
+ # xpath = f'.//div/span[normalize-space(text())="{dropdown_label}" and @class="{label_class_name}"]'
44
+ # span_element = wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
45
+ # span_element_id = span_element.get_attribute('id')
46
+ # return span_element_id
47
+
48
+ # @staticmethod
49
+ # def find_input_id(wait, label_text):
50
+ # label_class_name = "FieldLayout---field_label"
51
+ # xpath = f'.//div/div/label[@class="{label_class_name}" and contains(normalize-space(text()), "{label_text}")]'
52
+ # label_element = wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
53
+ # input_element_id = label_element.get_attribute('for')
54
+ # return input_element_id
55
+
56
+ # @staticmethod
57
+ # def set_input_value(wait, label_text, value):
58
+ # input_element_id = ComponentUtils.find_input_id(wait, label_text)
59
+ # input_element = ComponentUtils.set_input_value_using_id(wait, input_element_id, value)
60
+ # return input_element
61
+
62
+ # @staticmethod
63
+ # def set_input_value_using_id(wait, input_element_id, value):
64
+ # input_element = wait.until(EC.presence_of_element_located((By.ID, input_element_id)))
65
+ # input_element = wait.until(EC.element_to_be_clickable((By.ID, input_element_id)))
66
+ # input_element.clear()
67
+ # input_element.send_keys(value)
68
+ # input_element.send_keys(Keys.RETURN)
69
+ # return input_element
70
+
71
+ # @staticmethod
72
+ # def select_search_dropdown_value(wait, label, value):
73
+ # span_element_id = ComponentUtils.find_dropdown_id(wait, label)
74
+ # xpath = f'.//div[@id="{span_element_id}_value"]'
75
+ # combobox = wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
76
+ # disabled = combobox.get_attribute("aria-disabled")
77
+ # if disabled == "true":
78
+ # return
79
+ # aria_controls = combobox.get_attribute("aria-controls")
80
+ # combobox = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
81
+ # combobox.click()
82
+
83
+ # input_element_id = span_element_id + "_searchInput"
84
+ # ComponentUtils.set_input_value_using_id(wait, input_element_id, value)
85
+
86
+ # xpath = f'.//ul[@id="{aria_controls}"]/li[./div[normalize-space(text())="{value}"]]'
87
+ # component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
88
+ # component.click()
89
+
90
+ # @staticmethod
91
+ # def selectDropdownValue(wait, combobox, value):
92
+
93
+ # aria_controls = combobox.get_attribute("aria-controls")
94
+ # combobox.click()
95
+
96
+ # xpath = f'.//div/ul[@id="{aria_controls}"]/li[./div[normalize-space(text())="{value}"]]'
97
+ # component = wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
98
+ # component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
99
+ # component.click()
100
+
101
+ # @staticmethod
102
+ # def select_dropdown_value(wait, label, value):
103
+ # span_element_id = ComponentUtils.find_dropdown_id(wait, label)
104
+
105
+ # xpath = f'.//div[@id="{span_element_id}_value"]'
106
+ # combobox = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
107
+ # disabled = combobox.get_attribute("aria-disabled")
108
+ # if disabled == "true":
109
+ # return
110
+
111
+ # combobox = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
112
+ # ComponentUtils.selectDropdownValue(wait, combobox, value)
113
+
114
+ # @staticmethod
115
+ # def findButton(wait, button_text):
116
+ # xpath = f'.//button[.//span/span[contains(normalize-space(text()), "{button_text}")]]'
117
+ # component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
118
+ # return component
119
+
120
+ # @staticmethod
121
+ # def click_button(wait, button_text):
122
+ # component = ComponentUtils.findButton(wait, button_text)
123
+ # component.click()
124
+
125
+ # @staticmethod
126
+ # def select_tab(wait, tab_label_text):
127
+ # xpath = f'.//div[@role="presentation"]/div/div/p[./span[normalize-space(text())="{tab_label_text}"]]'
128
+ # component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
129
+ # component.click()
130
+
131
+ @staticmethod
132
+ def findSuccessMessage(wait: WebDriverWait, message: str):
133
+ """
134
+ Finds a success message in the UI by its text.
135
+ Parameters:
136
+ wait: Selenium WebDriverWait instance.
137
+ message: The text of the success message to find.
138
+ Returns:
139
+ The Selenium WebElement for the success message.
140
+ Example:
141
+ ComponentUtils.findSuccessMessage(wait, "Operation completed successfully")
142
+ """
143
+ # This method locates a success message that contains a strong tag with the specified text.
144
+ # The message is normalized to handle any extra spaces.
145
+ # It uses the presence_of_element_located condition to ensure the element is present in the DOM.
146
+
147
+ xpath = f'.//div/div/p/span/strong[normalize-space(text())="{message}"]'
148
+ component = wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
149
+ return component
150
+
151
+ @staticmethod
152
+ def findComponentUsingXpathAndClick(wait: WebDriverWait, xpath: str):
153
+ """
154
+ Finds a component using its XPath and clicks it.
155
+ Parameters:
156
+ wait: Selenium WebDriverWait instance.
157
+ xpath: The XPath of the component to find and click.
158
+ Example:
159
+ ComponentUtils.findComponentUsingXpathAndClick(wait, "//button[@id='submit']")
160
+
161
+ """
162
+ # This method locates a component using the provided XPath and clicks it.
163
+ # It uses the presence_of_element_located condition to ensure the element is present in the DOM.
164
+ # After locating the component, it clicks it to perform the action.
165
+ component = ComponentUtils.findComponentUsingXpath(wait, xpath)
166
+ component.click()
167
+
168
+ @staticmethod
169
+ def findComponentUsingXpath(wait: WebDriverWait, xpath: str):
170
+ """
171
+ Finds a component using its XPath.
172
+ Parameters:
173
+ wait: Selenium WebDriverWait instance.
174
+ xpath: The XPath of the component to find.
175
+ Returns:
176
+ The Selenium WebElement for the component.
177
+ Example:
178
+ ComponentUtils.findComponentUsingXpath(wait, "//button[@id='submit']")
179
+ """
180
+ # This method locates a component using the provided XPath.
181
+ # It uses the presence_of_element_located condition to ensure the element is present in the DOM.
182
+ # The method returns the WebElement for further interaction.
183
+ component = wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
184
+ return component
185
+
186
+ @staticmethod
187
+ def checkComponentExistsByXpath(wait: WebDriverWait, xpath: str):
188
+ """
189
+ Checks if a component exists using its XPath.
190
+ Parameters:
191
+ wait: Selenium WebDriverWait instance.
192
+ xpath: The XPath of the component to check.
193
+ Returns:
194
+ True if the component exists, False otherwise.
195
+ Example:
196
+ ComponentUtils.checkComponentExistsByXpath(wait, "//button[@id='submit']")
197
+ """
198
+ # This method checks if a component exists by attempting to find it using the provided XPath.
199
+ # If the component is found, it returns True; otherwise, it catches the NoSuchElementException and returns False.
200
+ # It uses the presence_of_element_located condition to ensure the element is present in the DOM.
201
+
202
+ status = False
203
+ try:
204
+ ComponentUtils.findComponentUsingXpath(wait, xpath)
205
+ status = True
206
+ except NoSuchElementException:
207
+ pass
208
+
209
+ return status
210
+
211
+ @staticmethod
212
+ def checkComponentExistsById(driver: WebDriver, id: str):
213
+ """
214
+ Checks if a component exists using its ID.
215
+ Parameters:
216
+ driver: Selenium WebDriver instance.
217
+ id: The ID of the component to check.
218
+ Returns:
219
+ True if the component exists, False otherwise.
220
+ Example:
221
+ ComponentUtils.checkComponentExistsById(driver, "submit-button")
222
+ """
223
+ # This method checks if a component exists by attempting to find it using the provided ID.
224
+ # If the component is found, it returns True; otherwise, it catches the NoSuchElementException and returns False.
225
+ # It uses the find_element method to locate the element by its ID.
226
+
227
+ status = False
228
+ try:
229
+ driver.find_element(By.ID, id)
230
+ status = True
231
+ except NoSuchElementException:
232
+ pass
233
+
234
+ return status
235
+
236
+ @staticmethod
237
+ def findCount(wait: WebDriverWait, xpath: str):
238
+ """
239
+ Finds the count of components matching the given XPath.
240
+ Parameters:
241
+ wait: Selenium WebDriverWait instance.
242
+ xpath: The XPath of the components to count.
243
+ Returns:
244
+ The count of components matching the XPath.
245
+ Example:
246
+ count = ComponentUtils.findCount(wait, "//div[@class='item']")
247
+ """
248
+ # This method locates all components matching the provided XPath and returns their count.
249
+ # It uses the presence_of_all_elements_located condition to ensure all elements are present in the DOM.
250
+ # If no elements are found, it catches the NoSuchElementException and returns 0.
251
+
252
+ length = 0
253
+
254
+ try:
255
+ component = wait.until(
256
+ EC.presence_of_all_elements_located((By.XPATH, xpath))
257
+ )
258
+ length = len(component)
259
+ except NoSuchElementException:
260
+ pass
261
+
262
+ return length
263
+
264
+ # @staticmethod
265
+ # def findComponent(wait, label):
266
+ # xpath = f".//div/label[text()='{label}']"
267
+ # component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
268
+ # component_id = component.get_attribute("for")
269
+
270
+ # component = wait.until(EC.element_to_be_clickable((By.ID, component_id)))
271
+ # return component
272
+
273
+ @staticmethod
274
+ def tab(driver: WebDriver):
275
+ """
276
+ Simulates a TAB key press in the browser.
277
+
278
+ Parameters:
279
+ driver: Selenium WebDriver instance.
280
+ Example:
281
+ ComponentUtils.tab(driver)
282
+ """
283
+ # This method simulates a TAB key press in the browser using ActionChains.
284
+ # It creates an ActionChains instance, sends the TAB key, and performs the action.
285
+ # This is useful for navigating through form fields or components in the UI.
286
+ # It uses the ActionChains class to perform the key press action.
287
+
288
+ actions = ActionChains(driver)
289
+ actions.send_keys(Keys.TAB).perform()
@@ -0,0 +1,130 @@
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.webdriver import WebDriver
5
+ from selenium.webdriver.remote.webelement import WebElement
6
+
7
+ from robo_appian.utils.components.InputUtils import InputUtils
8
+
9
+
10
+ class DateUtils:
11
+ """
12
+ Utility class for interacting with date components in Appian UI.
13
+
14
+ Usage Example:
15
+
16
+ # Set a date value
17
+ from robo_appian.utils.components.DateUtils import DateUtils
18
+ DateUtils.setDateValue(wait, "Start Date", "01/01/2024")
19
+
20
+ """
21
+
22
+ @staticmethod
23
+ def findComponent(wait: WebDriverWait, label: str):
24
+ """
25
+ Finds a date component by its label.
26
+
27
+ Parameters:
28
+ wait: Selenium WebDriverWait instance.
29
+ label: The visible text label of the date component.
30
+
31
+ Returns:
32
+ The Selenium WebElement for the date component.
33
+
34
+ Example:
35
+ DateUtils.findComponent(wait, "Start Date")
36
+
37
+ """
38
+
39
+ xpath = f".//div/label[text()='{label}']"
40
+ component: WebElement = wait.until(
41
+ EC.element_to_be_clickable((By.XPATH, xpath))
42
+ )
43
+ if not component:
44
+ raise ValueError(f"Could not find date component with label '{label}'.")
45
+
46
+ attribute: str = "for"
47
+ component_id = component.get_attribute(attribute) # type: ignore[reportUnknownMemberType]
48
+ if component_id is None:
49
+ raise ValueError(
50
+ f"Could not find component using {attribute} attribute for label '{label}'."
51
+ )
52
+
53
+ component = wait.until(EC.element_to_be_clickable((By.ID, component_id)))
54
+ return component
55
+
56
+ @staticmethod
57
+ def setDateValue(wait: WebDriverWait, label: str, value: str):
58
+ """
59
+ Sets a date value in a date component identified by its label.
60
+
61
+ Parameters:
62
+ wait: Selenium WebDriverWait instance.
63
+ label: The visible text label of the date component.
64
+ value: The date value to set (e.g., "01/01/2024").
65
+
66
+ Returns:
67
+ The Selenium WebElement for the date component after setting the value.
68
+
69
+ Example:
70
+ DateUtils.setDateValue(wait, "Start Date", "01/01/2024")
71
+
72
+ """
73
+ # This method locates a date component that contains a label with the specified text.
74
+ # It then retrieves the component's ID and uses it to find the actual input element.
75
+ # component = wait.until(EC.element_to_be_clickable((By.XPATH, f".//div/label[text()='{label}']/following-sibling::input")))
76
+
77
+ component = DateUtils.findComponent(wait, label)
78
+ InputUtils.setValueUsingComponent(component, value)
79
+ return component
80
+
81
+ @staticmethod
82
+ def setDateValueAndSubmit(wait: WebDriverWait, label: str, value: str):
83
+ """
84
+ Sets a date value in a date component identified by its label and submits the form.
85
+
86
+ Parameters:
87
+ wait: Selenium WebDriverWait instance.
88
+ label: The visible text label of the date component.
89
+ value: The date value to set (e.g., "01/01/2024").
90
+
91
+ Returns:
92
+ The Selenium WebElement for the date component after setting the value.
93
+
94
+ Example:
95
+ DateUtils.setDateValueAndSubmit(wait, "Start Date", "01/01/2024")
96
+
97
+ """
98
+
99
+ # This method locates a date component that contains a label with the specified text.
100
+ # It then retrieves the component's ID and uses it to find the actual input element.
101
+ # It sets the value of the input element and submits it.
102
+
103
+ component = DateUtils.findComponent(wait, label)
104
+ InputUtils.setValueAndSubmitUsingComponent(component, value)
105
+
106
+ return component
107
+
108
+ @staticmethod
109
+ def click(wait: WebDriverWait, label: str):
110
+ """
111
+ Clicks on a date component identified by its label.
112
+
113
+ Parameters:
114
+ wait: Selenium WebDriverWait instance.
115
+ label: The visible text label of the date component.
116
+
117
+ Returns:
118
+ The Selenium WebElement for the date component after clicking.
119
+
120
+ Example:
121
+ DateUtils.click(wait, "Start Date")
122
+ """
123
+ # This method locates a date component that contains a label with the specified text.
124
+ # It then retrieves the component's ID and uses it to find the actual input element.
125
+ # It clicks on the input element to open the date picker.
126
+
127
+ component = DateUtils.findComponent(wait, label)
128
+ component.click()
129
+
130
+ return component
@@ -0,0 +1,141 @@
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.webdriver import WebDriver
5
+ from selenium.webdriver.remote.webelement import WebElement
6
+
7
+ from robo_appian.utils.components.InputUtils import InputUtils
8
+
9
+
10
+ class DropdownUtils:
11
+ """
12
+ Utility class for interacting with dropdown components in Appian UI.
13
+
14
+ Usage Example:
15
+
16
+ # Select a value from a dropdown
17
+ from robo_appian.utils.components.DropdownUtils import DropdownUtils
18
+ DropdownUtils.selectDropdownValue(wait, "Status", "Approved")
19
+
20
+ # Select a value from a search dropdown
21
+ from robo_appian.utils.components.DropdownUtils import DropdownUtils
22
+ DropdownUtils.selectSearchDropdownValue(wait, "Category", "Finance")
23
+ """
24
+
25
+ @staticmethod
26
+ def findDropdownEnabled(wait: WebDriverWait, dropdown_label: str):
27
+ """
28
+ Finds a dropdown component that is enabled and has the specified label.
29
+
30
+ Parameters:
31
+ wait: Selenium WebDriverWait instance.
32
+ dropdown_label: The visible text label of the dropdown component.
33
+
34
+ Returns:
35
+ The Selenium WebElement for the dropdown component.
36
+
37
+ Example:
38
+ DropdownUtils.findDropdownEnabled(wait, "Status")
39
+
40
+ """
41
+ # This method locates a dropdown component that contains a label with the specified text.
42
+ # It then retrieves the component's ID and uses it to find the actual dropdown element.
43
+ # The dropdown is identified by its role as a combobox and tabindex attribute.
44
+ # The XPath searches for a div that contains a span with the specified label text.
45
+ # It ensures that the dropdown is clickable and ready for interaction.
46
+ # The dropdown component is expected to have a structure where the label is within a span inside a div.
47
+
48
+ xpath = f'.//div[./div/span[normalize-space(text())="{dropdown_label}"]]/div/div/div/div[@role="combobox" and @tabindex="0"]'
49
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
50
+ return component
51
+
52
+ @staticmethod
53
+ def selectValueUsingComponent(
54
+ wait: WebDriverWait,
55
+ combobox: WebElement,
56
+ value: str
57
+ ) -> None:
58
+ """
59
+ Selects a value from a dropdown component using the provided combobox element.
60
+
61
+ Parameters:
62
+ wait: Selenium WebDriverWait instance.
63
+ combobox: The Selenium WebElement for the combobox.
64
+ value: The value to select from the dropdown.
65
+
66
+ Example:
67
+ DropdownUtils.selectValueUsingComponent(wait, combobox, "Approved")
68
+
69
+ """
70
+ # This method assumes that the combobox is already found and passed as an argument.
71
+ # It retrieves the aria-controls attribute to find the dropdown list and selects the specified value.
72
+
73
+ if not combobox:
74
+ raise ValueError(f"Dropdown component object is not valid.")
75
+
76
+ component: WebElement = combobox.find_element(By.XPATH, "./div/div") # type: ignore[reportUnknownMemberType]
77
+ aria_controls = component.get_attribute("aria-controls") # type: ignore[reportUnknownMemberType]
78
+ component.click()
79
+
80
+ xpath = f'.//div/ul[@id="{aria_controls}"]/li[./div[normalize-space(text())="{value}"]]'
81
+ # component = wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
82
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
83
+ component.click()
84
+
85
+ @staticmethod
86
+ def selectDropdownValue(wait: WebDriverWait, label: str, value: str) -> None:
87
+ """
88
+ Selects a value from a dropdown component identified by its label.
89
+
90
+ Parameters:
91
+ wait: Selenium WebDriverWait instance.
92
+ label: The visible text label of the dropdown component.
93
+ value: The value to select from the dropdown.
94
+
95
+ Example:
96
+ DropdownUtils.selectDropdownValue(wait, "Status", "Approved")
97
+
98
+ """
99
+ # This method finds the dropdown component by its label, retrieves the aria-controls attribute,
100
+ # and then clicks on the dropdown to display the options.
101
+
102
+ combobox = DropdownUtils.findDropdownEnabled(wait, label)
103
+ aria_controls = combobox.get_attribute("aria-controls") # type: ignore[reportUnknownMemberType]
104
+ combobox.click()
105
+
106
+ xpath = f'.//div/ul[@id="{aria_controls}"]/li[./div[normalize-space(text())="{value}"]]'
107
+ component = wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
108
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
109
+ component.click()
110
+
111
+ @staticmethod
112
+ def selectSearchDropdownValue(wait: WebDriverWait, dropdown_label: str, value: str):
113
+ """
114
+ Selects a value from a search-enabled dropdown component identified by its label.
115
+
116
+ Parameters:
117
+ wait: Selenium WebDriverWait instance.
118
+ dropdown_label: The visible text label of the search dropdown component.
119
+ value: The value to select from the dropdown.
120
+
121
+ Example:
122
+ DropdownUtils.selectSearchDropdownValue(wait, "Category", "Finance")
123
+
124
+ """
125
+ # This method finds the search-enabled dropdown component by its label, retrieves the aria-controls attribute
126
+ # and the component ID, clicks on the dropdown to display the search input,
127
+
128
+ component = DropdownUtils.findDropdownEnabled(wait, dropdown_label)
129
+ component_id = component.get_attribute("aria-labelledby") # type: ignore[reportUnknownMemberType]
130
+ aria_controls = component.get_attribute("aria-controls") # type: ignore[reportUnknownMemberType]
131
+ component.click()
132
+
133
+ input_component_id = str(component_id) + "_searchInput"
134
+ input_component = wait.until(
135
+ EC.element_to_be_clickable((By.ID, input_component_id))
136
+ )
137
+ InputUtils.setValueUsingComponent(input_component, value)
138
+
139
+ xpath = f'.//ul[@id="{aria_controls}"]/li[./div[normalize-space(text())="{value}"]][1]'
140
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
141
+ component.click()