robo_appian 0.0.10__tar.gz → 0.0.11__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 (23) hide show
  1. {robo_appian-0.0.10 → robo_appian-0.0.11}/PKG-INFO +1 -1
  2. {robo_appian-0.0.10 → robo_appian-0.0.11}/pyproject.toml +1 -1
  3. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/components/ButtonUtils.py +3 -43
  4. robo_appian-0.0.11/robo_appian/components/DropdownUtils.py +132 -0
  5. robo_appian-0.0.11/robo_appian/components/SearchDropdownUtils.py +75 -0
  6. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/controllers/ComponentDriver.py +3 -6
  7. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/utils/ComponentUtils.py +6 -3
  8. robo_appian-0.0.10/robo_appian/components/DropdownUtils.py +0 -177
  9. {robo_appian-0.0.10 → robo_appian-0.0.11}/LICENSE +0 -0
  10. {robo_appian-0.0.10 → robo_appian-0.0.11}/README.md +0 -0
  11. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/__init__.py +0 -0
  12. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/components/DateUtils.py +0 -0
  13. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/components/InputUtils.py +0 -0
  14. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/components/LabelUtils.py +0 -0
  15. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/components/LinkUtils.py +0 -0
  16. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/components/SearchInputUtils.py +0 -0
  17. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/components/TabUtils.py +0 -0
  18. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/components/TableUtils.py +0 -0
  19. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/components/__init__.py +0 -0
  20. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/controllers/__init__.py +0 -0
  21. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/exceptions/MyCustomError.py +0 -0
  22. {robo_appian-0.0.10 → robo_appian-0.0.11}/robo_appian/exceptions/__init__.py +0 -0
  23. {robo_appian-0.0.10 → robo_appian-0.0.11}/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.11
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.11"
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,49 +4,13 @@ from selenium.webdriver.support.ui import WebDriverWait
4
4
 
5
5
 
6
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.components.ButtonUtils import ButtonUtils
14
-
15
- wait = WebDriverWait(driver, 10)
16
- ButtonUtils.click(wait, "Login")
17
-
18
- """
19
-
20
7
  @staticmethod
21
8
  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
9
  xpath = f".//button[./span[contains(translate(normalize-space(.), '\u00a0', ' '), '{label}')]]"
40
10
  try:
41
11
  component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
42
- except TimeoutError as e:
43
- raise TimeoutError(
44
- f"Button with label '{label}' not found or not clickable."
45
- ) from e
46
12
  except Exception as e:
47
- raise RuntimeError(
48
- f"Button with label '{label}' not found or not clickable."
49
- ) from e
13
+ raise RuntimeError(f"Button with label '{label}' not found or not clickable.") from e
50
14
  return component
51
15
 
52
16
  @staticmethod
@@ -80,12 +44,8 @@ class ButtonUtils:
80
44
  try:
81
45
  component = wait.until(EC.element_to_be_clickable((By.ID, id)))
82
46
  except TimeoutError as e:
83
- raise TimeoutError(
84
- f"Input button with id '{id}' not found or not clickable."
85
- ) from e
47
+ raise TimeoutError(f"Input button with id '{id}' not found or not clickable.") from e
86
48
  except Exception as e:
87
- raise RuntimeError(
88
- f"Input button with id '{id}' not found or not clickable."
89
- ) from e
49
+ raise RuntimeError(f"Input button with id '{id}' not found or not clickable.") from e
90
50
 
91
51
  component.click()
@@ -0,0 +1,132 @@
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
+ xpath = f'.//div[./div/span[contains(normalize-space(text()), "{label}")]]/div/div/div/div[@role="combobox" and not(@aria-disabled="true")]'
20
+ try:
21
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
22
+ except Exception as e:
23
+ raise Exception(f'Could not find combobox with partial label "{label}" : {str(e)}')
24
+
25
+ return component
26
+
27
+ @staticmethod
28
+ 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")]'
30
+ try:
31
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
32
+ except Exception as e:
33
+ raise Exception(f'Could not find combobox with label "{label}" : {str(e)}')
34
+
35
+ return component
36
+
37
+ @staticmethod
38
+ def __clickCombobox(wait: WebDriverWait, combobox: WebElement):
39
+ combobox.click()
40
+
41
+ @staticmethod
42
+ def __findDropdownOptionId(wait: WebDriverWait, combobox: WebElement):
43
+ dropdown_option_id = combobox.get_attribute("aria-controls")
44
+ if dropdown_option_id is None:
45
+ raise Exception('Dropdown component does not have a valid "aria-controls" attribute.')
46
+ return dropdown_option_id
47
+
48
+ @staticmethod
49
+ 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}"]]'
51
+ try:
52
+ wait.until(EC.element_to_be_clickable((By.XPATH, option_xpath)))
53
+ return True
54
+ except NoSuchElementException:
55
+ return False
56
+ except Exception as e:
57
+ raise Exception(f'Could not find dropdown option "{value}" with dropdown option id "{dropdown_option_id}": {str(e)}')
58
+
59
+ @staticmethod
60
+ def __selectDropdownValueByDropdownOptionId(wait: WebDriverWait, dropdown_option_id: str, value: str):
61
+ option_xpath = f'.//div/ul[@id="{dropdown_option_id}"]/li[./div[normalize-space(text())="{value}"]]'
62
+ try:
63
+ try:
64
+ component = wait.until(EC.presence_of_element_located((By.XPATH, option_xpath)))
65
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, option_xpath)))
66
+ except Exception as e:
67
+ raise Exception(
68
+ f'Could not locate or click dropdown option "{value}" with dropdown option id "{dropdown_option_id}": {str(e)}'
69
+ )
70
+ except Exception as e:
71
+ raise Exception(f'Could not find or click dropdown option "{value}" with xpath "{option_xpath}": {str(e)}')
72
+ component.click()
73
+
74
+ @staticmethod
75
+ def __selectDropdownValueByPartialLabelText(wait: WebDriverWait, label: str, value: str):
76
+ """
77
+ Selects a value from a dropdown by its label text.
78
+
79
+ :param wait: WebDriverWait instance to wait for elements.
80
+ :param label: The label of the dropdown.
81
+ :param value: The value to select from the dropdown.
82
+ """
83
+ combobox = DropdownUtils.__findComboboxByPartialLabelText(wait, label)
84
+ DropdownUtils.__clickCombobox(wait, combobox)
85
+ dropdown_option_id = DropdownUtils.__findDropdownOptionId(wait, combobox)
86
+ DropdownUtils.__selectDropdownValueByDropdownOptionId(wait, dropdown_option_id, value)
87
+
88
+ @staticmethod
89
+ def __selectDropdownValueByLabelText(wait: WebDriverWait, label: str, value: str):
90
+ """
91
+ Selects a value from a dropdown by its label text.
92
+
93
+ :param wait: WebDriverWait instance to wait for elements.
94
+ :param label: The label of the dropdown.
95
+ :param value: The value to select from the dropdown.
96
+ """
97
+ combobox = DropdownUtils.__findComboboxByLabelText(wait, label)
98
+ DropdownUtils.__clickCombobox(wait, combobox)
99
+ dropdown_option_id = DropdownUtils.__findDropdownOptionId(wait, combobox)
100
+ DropdownUtils.__selectDropdownValueByDropdownOptionId(wait, dropdown_option_id, value)
101
+
102
+ @staticmethod
103
+ def checkReadOnlyStatusByLabelText(wait: WebDriverWait, label: str):
104
+ xpath = f'.//div[./div/span[normalize-space(text())="{label}"]]/div/div/p[text()]'
105
+ try:
106
+ wait._driver.find_element(By.XPATH, xpath)
107
+ return True
108
+ except NoSuchElementException:
109
+ return False
110
+ except Exception:
111
+ raise Exception(f'Error checking read-only status for label "{label}"')
112
+
113
+ @staticmethod
114
+ def selectDropdownValueByComboboxComponent(wait: WebDriverWait, combobox: WebElement, value: str):
115
+ dropdown_option_id = DropdownUtils.__findDropdownOptionId(wait, combobox)
116
+ DropdownUtils.__clickCombobox(wait, combobox)
117
+ DropdownUtils.__selectDropdownValueByDropdownOptionId(wait, dropdown_option_id, value)
118
+
119
+ @staticmethod
120
+ def selectDropdownValueByLabelText(wait: WebDriverWait, dropdown_label: str, value: str):
121
+ DropdownUtils.__selectDropdownValueByLabelText(wait, dropdown_label, value)
122
+
123
+ @staticmethod
124
+ def selectDropdownValueByPartialLabelText(wait: WebDriverWait, dropdown_label: str, value: str):
125
+ DropdownUtils.__selectDropdownValueByPartialLabelText(wait, dropdown_label, value)
126
+
127
+ @staticmethod
128
+ def checkDropdownOptionValueExists(wait: WebDriverWait, dropdown_label: str, value: str):
129
+ combobox = DropdownUtils.__findComboboxByLabelText(wait, dropdown_label)
130
+ DropdownUtils.__clickCombobox(wait, combobox)
131
+ dropdown_option_id = DropdownUtils.__findDropdownOptionId(wait, combobox)
132
+ return DropdownUtils.__checkDropdownOptionValueExistsByDropdownOptionId(wait, dropdown_option_id, value)
@@ -0,0 +1,75 @@
1
+ from selenium.webdriver.support.ui import WebDriverWait
2
+ from selenium.webdriver.support import expected_conditions as EC
3
+ from selenium.webdriver.common.by import By
4
+ from robo_appian.components.InputUtils import InputUtils
5
+
6
+
7
+ class SearchDropdownUtils:
8
+ """
9
+ Utility class for interacting with search dropdown components in Appian UI.
10
+ Usage Example:
11
+ # Select a value from a search dropdown
12
+ from robo_appian.components.SearchDropdownUtils import SearchDropdownUtils
13
+ SearchDropdownUtils.selectSearchDropdownValueByLabelText(wait, "Status", "Approved")
14
+ """
15
+
16
+ @staticmethod
17
+ def __selectSearchDropdownValueByDropdownOptionId(wait, component_id, dropdown_option_id, value):
18
+ input_component_id = str(component_id) + "_searchInput"
19
+ try:
20
+ input_component = wait.until(EC.element_to_be_clickable((By.ID, input_component_id)))
21
+ except Exception as e:
22
+ raise RuntimeError(f"Failed to locate or click input component with ID '{input_component_id}': {e}")
23
+ InputUtils._setComponentValue(input_component, value)
24
+
25
+ xpath = f'.//ul[@id="{dropdown_option_id}"]/li[./div[normalize-space(text())="{value}"]][1]'
26
+ try:
27
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
28
+ except Exception as e:
29
+ raise RuntimeError(f"Failed to locate or click dropdown option with XPath '{xpath}': {e}")
30
+ component.click()
31
+
32
+ @staticmethod
33
+ def __selectSearchDropdownValueByPartialLabelText(wait: WebDriverWait, label: str, value: str):
34
+ xpath = f'.//div[./div/span[contains(normalize-space(text()), "{label}")]]/div/div/div/div[@role="combobox" and not(@aria-disabled="true")]'
35
+ try:
36
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
37
+ except Exception as e:
38
+ raise RuntimeError(f"Failed to locate or click dropdown component with XPath '{xpath}': {e}")
39
+ component_id = component.get_attribute("aria-labelledby")
40
+ dropdown_id = component.get_attribute("aria-controls")
41
+ component.click()
42
+
43
+ SearchDropdownUtils.__selectSearchDropdownValueByDropdownOptionId(wait, component_id, dropdown_id, value)
44
+
45
+ @staticmethod
46
+ def __selectSearchDropdownValueByLabelText(wait: WebDriverWait, label: str, value: str):
47
+ xpath = f'.//div[./div/span[normalize-space(text())="{label}"]]/div/div/div/div[@role="combobox" and not(@aria-disabled="true")]'
48
+ try:
49
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
50
+ except Exception as e:
51
+ raise RuntimeError(f"Failed to locate or click dropdown component with XPath '{xpath}': {e}")
52
+ component_id = component.get_attribute("aria-labelledby")
53
+ dropdown_option_id = component.get_attribute("aria-controls")
54
+ component.click()
55
+ SearchDropdownUtils.__selectSearchDropdownValueByDropdownOptionId(wait, component_id, dropdown_option_id, value)
56
+
57
+ @staticmethod
58
+ def selectSearchDropdownValueByLabelText(wait: WebDriverWait, dropdown_label: str, value: str):
59
+ """Selects a value from a search dropdown by label text.
60
+ Args:
61
+ wait (WebDriverWait): The WebDriverWait instance to use for waiting.
62
+ dropdown_label (str): The label text of the dropdown.
63
+ value (str): The value to select from the dropdown.
64
+ """
65
+ SearchDropdownUtils.__selectSearchDropdownValueByLabelText(wait, dropdown_label, value)
66
+
67
+ @staticmethod
68
+ def selectSearchDropdownValueByPartialLabelText(wait: WebDriverWait, dropdown_label: str, value: str):
69
+ """Selects a value from a search dropdown by partial label text.
70
+ Args:
71
+ wait (WebDriverWait): The WebDriverWait instance to use for waiting.
72
+ dropdown_label (str): The label text of the dropdown.
73
+ value (str): The value to select from the dropdown.
74
+ """
75
+ SearchDropdownUtils.__selectSearchDropdownValueByPartialLabelText(wait, dropdown_label, value)
@@ -7,6 +7,7 @@ from robo_appian.components.LabelUtils import LabelUtils
7
7
  from robo_appian.components.LinkUtils import LinkUtils
8
8
  from robo_appian.components.TabUtils import TabUtils
9
9
  from robo_appian.components.SearchInputUtils import SearchInputUtils
10
+ from robo_appian.components.SearchDropdownUtils import SearchDropdownUtils
10
11
 
11
12
 
12
13
  class ComponentDriver:
@@ -49,9 +50,7 @@ class ComponentDriver:
49
50
  case "Search Input Text":
50
51
  match action:
51
52
  case "Select":
52
- SearchInputUtils.selectSearchDropdownByLabelText(
53
- wait, label, value
54
- )
53
+ SearchInputUtils.selectSearchDropdownByLabelText(wait, label, value)
55
54
  case _:
56
55
  raise ValueError(f"Unsupported action for {type}: {action}")
57
56
  case "Label":
@@ -75,9 +74,7 @@ class ComponentDriver:
75
74
  case "Search Drop Down":
76
75
  match action:
77
76
  case "Select":
78
- DropdownUtils.selectSearchDropdownValueByLabelText(
79
- wait, label, value
80
- )
77
+ SearchDropdownUtils.selectSearchDropdownValueByLabelText(wait, label, value)
81
78
  case _:
82
79
  raise ValueError(f"Unsupported action for {type}: {action}")
83
80
  case "Button":
@@ -4,6 +4,7 @@ from selenium.webdriver.common.by import By
4
4
  from selenium.webdriver.common.keys import Keys
5
5
  from selenium.webdriver.support import expected_conditions as EC
6
6
  from selenium.webdriver.remote.webdriver import WebDriver
7
+ from selenium.webdriver.remote.webelement import WebElement
7
8
  from selenium.webdriver.support.ui import WebDriverWait
8
9
 
9
10
 
@@ -37,6 +38,10 @@ class ComponentUtils:
37
38
  yesterday_formatted = yesterday.strftime("%m/%d/%Y")
38
39
  return yesterday_formatted
39
40
 
41
+ @staticmethod
42
+ def findChildComponent(wait: WebDriverWait, component: WebElement, xpath: str):
43
+ return component.find_element(By.XPATH, xpath)
44
+
40
45
  @staticmethod
41
46
  def findSuccessMessage(wait: WebDriverWait, message: str):
42
47
  """
@@ -161,9 +166,7 @@ class ComponentUtils:
161
166
  length = 0
162
167
 
163
168
  try:
164
- component = wait.until(
165
- EC.presence_of_all_elements_located((By.XPATH, xpath))
166
- )
169
+ component = wait.until(EC.presence_of_all_elements_located((By.XPATH, xpath)))
167
170
  length = len(component)
168
171
  except NoSuchElementException:
169
172
  pass
@@ -1,177 +0,0 @@
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
-
6
- from robo_appian.components.InputUtils import InputUtils
7
-
8
-
9
- class DropdownUtils:
10
- """
11
- Utility class for interacting with dropdown components in Appian UI.
12
-
13
- Usage Example:
14
-
15
- # Select a value from a dropdown
16
- from robo_appian.components.DropdownUtils import DropdownUtils
17
- DropdownUtils.selectDropdownValueByLabelText(wait, "Status", "Approved")
18
-
19
- # Select a value from a search dropdown
20
- from robo_appian.components.DropdownUtils import DropdownUtils
21
- DropdownUtils.selectSearchDropdownValueByLabelText(wait, "Category", "Finance")
22
- """
23
-
24
- @staticmethod
25
- def __findDropdownComponentsByXpath(wait: WebDriverWait, xpath: str):
26
- try:
27
- # Wait for at least one element to be present
28
- try:
29
- wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
30
- except TimeoutError as e:
31
- raise TimeoutError(
32
- f'No clickable dropdown component found for xpath "{xpath}": {str(e)}'
33
- )
34
- except Exception as e:
35
- raise Exception(
36
- f'No clickable dropdown component found for xpath "{xpath}": {str(e)}'
37
- )
38
-
39
- # Find all matching elements
40
- driver = wait._driver
41
- components = driver.find_elements(By.XPATH, xpath)
42
-
43
- # Filter for clickable and displayed components
44
- valid_components = []
45
- for component in components:
46
- try:
47
- if component.is_displayed() and component.is_enabled():
48
- valid_components.append(component)
49
- except Exception:
50
- continue
51
-
52
- if not valid_components:
53
- raise Exception(
54
- f'No valid dropdown components with xpath "{xpath}" found.'
55
- )
56
-
57
- # Return single component if only one found, list if multiple
58
- return valid_components
59
-
60
- except Exception as e:
61
- raise Exception(
62
- f'Dropdown component with xpath "{xpath}" not found: {str(e)}'
63
- )
64
-
65
- @staticmethod
66
- def selectDropdownValueByComponent(wait, combobox, value):
67
- dropdown_id = combobox.get_attribute("aria-controls")
68
- combobox.click()
69
-
70
- option_xpath = f'.//div/ul[@id="{dropdown_id}"]/li[./div[normalize-space(text())="{value}"]]'
71
- try:
72
- component = wait.until(
73
- EC.presence_of_element_located((By.XPATH, option_xpath))
74
- )
75
- component = wait.until(EC.element_to_be_clickable((By.XPATH, option_xpath)))
76
- except TimeoutError as e:
77
- raise TimeoutError(
78
- f'Could not find or click dropdown option "{value}" with xpath "{option_xpath}": {str(e)}'
79
- )
80
- except Exception as e:
81
- raise Exception(
82
- f'Could not find or click dropdown option "{value}" with xpath "{option_xpath}": {str(e)}'
83
- )
84
- component.click()
85
-
86
- @staticmethod
87
- def __selectDropdownValueByXpath(wait, xpath, value):
88
- components = DropdownUtils.__findDropdownComponentsByXpath(wait, xpath)
89
- for combobox in components:
90
- if combobox.is_displayed() and combobox.is_enabled():
91
- DropdownUtils.selectDropdownValueByComponent(wait, combobox, value)
92
-
93
- @staticmethod
94
- def selectDropdownValueByLabelText(
95
- wait: WebDriverWait, dropdown_label: str, value: str
96
- ):
97
- xpath = f'.//div[./div/span[normalize-space(text())="{dropdown_label}"]]/div/div/div/div[@role="combobox" and @tabindex="0"]'
98
- DropdownUtils.__selectDropdownValueByXpath(wait, xpath, value)
99
-
100
- @staticmethod
101
- def selectDropdownValueByPartialLabelText(
102
- wait: WebDriverWait, dropdown_label: str, value: str
103
- ):
104
- xpath = f'.//div[./div/span[contains(normalize-space(text()), "{dropdown_label}")]]/div/div/div/div[@role="combobox" and @tabindex="0"]'
105
- DropdownUtils.__selectDropdownValueByXpath(wait, xpath, value)
106
-
107
- @staticmethod
108
- def __selectSearchDropdownValueByXpath(wait, xpath, value):
109
- components = DropdownUtils.__findDropdownComponentsByXpath(wait, xpath)
110
-
111
- for component in components:
112
- if component.is_displayed() and component.is_enabled():
113
- component_id = component.get_attribute("aria-labelledby") # type: ignore[reportUnknownMemberType]
114
- dropdown_id = component.get_attribute("aria-controls") # type: ignore[reportUnknownMemberType]
115
- component.click()
116
-
117
- input_component_id = str(component_id) + "_searchInput"
118
- try:
119
- input_component = wait.until(
120
- EC.element_to_be_clickable((By.ID, input_component_id))
121
- )
122
- except TimeoutError as e:
123
- raise TimeoutError(
124
- f'Could not find or click search input component with id "{input_component_id}": {str(e)}'
125
- )
126
- except Exception as e:
127
- raise Exception(
128
- f'Could not find or click search input component with id "{input_component_id}": {str(e)}'
129
- )
130
- InputUtils._setComponentValue(input_component, value)
131
-
132
- xpath = f'.//ul[@id="{dropdown_id}"]/li[./div[normalize-space(text())="{value}"]][1]'
133
- try:
134
- component = wait.until(
135
- EC.element_to_be_clickable((By.XPATH, xpath))
136
- )
137
- except TimeoutError as e:
138
- raise TimeoutError(
139
- f'Could not find or click search dropdown option "{value}" with xpath "{xpath}": {str(e)}'
140
- )
141
- except Exception as e:
142
- raise Exception(
143
- f'Could not find or click search dropdown option "{value}" with xpath "{xpath}": {str(e)}'
144
- )
145
- component.click()
146
-
147
- @staticmethod
148
- def selectSearchDropdownValueByLabelText(
149
- wait: WebDriverWait, dropdown_label: str, value: str
150
- ):
151
- xpath = f'.//div[./div/span[normalize-space(text())="{dropdown_label}"]]/div/div/div/div[@role="combobox" and @tabindex="0"]'
152
- DropdownUtils.__selectSearchDropdownValueByXpath(wait, xpath, value)
153
-
154
- @staticmethod
155
- def selectSearchDropdownValueByPartialLabelText(
156
- wait: WebDriverWait, dropdown_label: str, value: str
157
- ):
158
- xpath = f'.//div[./div/span[contains(normalize-space(text()), "{dropdown_label}")]]/div/div/div/div[@role="combobox" and @tabindex="0"]'
159
- DropdownUtils.__selectSearchDropdownValueByXpath(wait, xpath, value)
160
-
161
- @staticmethod
162
- def selectValueByDropdownWrapperComponent(
163
- wait: WebDriverWait, component: WebElement, value: str
164
- ):
165
- xpath = './div/div[@role="combobox" and @tabindex="0"]'
166
- try:
167
- combobox = component.find_element(By.XPATH, xpath)
168
- except TimeoutError as e:
169
- raise TimeoutError(
170
- f'Could not find combobox element with xpath "{xpath}" in the provided component: {str(e)}'
171
- )
172
- except Exception as e:
173
- raise Exception(
174
- f'Could not find combobox element with xpath "{xpath}" in the provided component: {str(e)}'
175
- )
176
- DropdownUtils.selectDropdownValueByComponent(wait, combobox, value)
177
- return combobox
File without changes
File without changes