robo_appian 0.0.9__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.9 → robo_appian-0.0.11}/PKG-INFO +1 -1
  2. {robo_appian-0.0.9 → robo_appian-0.0.11}/pyproject.toml +1 -1
  3. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/components/ButtonUtils.py +3 -43
  4. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/components/DateUtils.py +1 -1
  5. robo_appian-0.0.11/robo_appian/components/DropdownUtils.py +132 -0
  6. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/components/InputUtils.py +5 -5
  7. robo_appian-0.0.11/robo_appian/components/SearchDropdownUtils.py +75 -0
  8. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/components/TabUtils.py +6 -6
  9. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/components/TableUtils.py +9 -94
  10. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/controllers/ComponentDriver.py +4 -7
  11. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/utils/ComponentUtils.py +7 -4
  12. robo_appian-0.0.9/robo_appian/components/DropdownUtils.py +0 -177
  13. {robo_appian-0.0.9 → robo_appian-0.0.11}/LICENSE +0 -0
  14. {robo_appian-0.0.9 → robo_appian-0.0.11}/README.md +0 -0
  15. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/__init__.py +0 -0
  16. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/components/LabelUtils.py +0 -0
  17. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/components/LinkUtils.py +0 -0
  18. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/components/SearchInputUtils.py +0 -0
  19. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/components/__init__.py +0 -0
  20. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/controllers/__init__.py +0 -0
  21. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/exceptions/MyCustomError.py +0 -0
  22. {robo_appian-0.0.9 → robo_appian-0.0.11}/robo_appian/exceptions/__init__.py +0 -0
  23. {robo_appian-0.0.9 → 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.9
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.9"
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()
@@ -116,7 +116,7 @@ class DateUtils:
116
116
  # It sets the value of the input element and submits it.
117
117
 
118
118
  component = DateUtils.findComponent(wait, label)
119
- InputUtils.setValueAndSubmitUsingComponent(component, value)
119
+ InputUtils.setValueAndSubmitByComponent(component, value)
120
120
 
121
121
  return component
122
122
 
@@ -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)
@@ -19,7 +19,7 @@ class InputUtils:
19
19
  """
20
20
 
21
21
  @staticmethod
22
- def setValueAndSubmitUsingComponent(component: WebElement, value: str):
22
+ def setValueAndSubmitByComponent(component: WebElement, value: str):
23
23
  """
24
24
  Sets a value in an input component and submits it using the provided component element.
25
25
 
@@ -31,7 +31,7 @@ class InputUtils:
31
31
  The Selenium WebElement for the input component after setting the value and submitting.
32
32
 
33
33
  Example:
34
- InputUtils.setValueAndSubmitUsingComponent(component, "test_user")
34
+ InputUtils.setValueAndSubmitByComponent(component, "test_user")
35
35
 
36
36
  """
37
37
  # This method assumes that the component is already found and passed as an argument.
@@ -46,7 +46,7 @@ class InputUtils:
46
46
  return component
47
47
 
48
48
  @staticmethod
49
- def __findInputComponentsByLabelPath(wait: WebDriverWait, xpath: str):
49
+ def __findInputComponentsByXpath(wait: WebDriverWait, xpath: str):
50
50
  label_components = ComponentUtils.findComponentsByXPath(wait, xpath)
51
51
  input_components = []
52
52
  for label_component in label_components:
@@ -71,13 +71,13 @@ class InputUtils:
71
71
  @staticmethod
72
72
  def __findInputComponentsByPartialLabel(wait: WebDriverWait, label: str):
73
73
  xpath = f'.//div/label[contains(normalize-space(text()), "{label}")]'
74
- components = InputUtils.__findInputComponentsByLabelPath(wait, xpath)
74
+ components = InputUtils.__findInputComponentsByXpath(wait, xpath)
75
75
  return components
76
76
 
77
77
  @staticmethod
78
78
  def __findInputComponentsByLabel(wait: WebDriverWait, label: str):
79
79
  xpath = f'.//div/label[normalize-space(text())="{label}"]'
80
- components = InputUtils.__findInputComponentsByLabelPath(wait, xpath)
80
+ components = InputUtils.__findInputComponentsByXpath(wait, xpath)
81
81
  return components
82
82
 
83
83
  @staticmethod
@@ -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)
@@ -10,15 +10,15 @@ class TabUtils:
10
10
 
11
11
  # Select a tab by its label
12
12
  from robo_appian.components.TabUtils import TabUtils
13
- TabUtils.select_tab(wait, "Settings")
13
+ TabUtils.selectInactiveTab(wait, "Settings")
14
14
 
15
15
  # Find the currently selected tab by its label
16
16
  from robo_appian.components.TabUtils import TabUtils
17
- selected_tab = TabUtils.find_selected_tab(wait, "Settings")
17
+ selected_tab = TabUtils.findSelectedTab(wait, "Settings")
18
18
  """
19
19
 
20
20
  @staticmethod
21
- def find_selected_tab(wait, label):
21
+ def findSelectedTab(wait, label):
22
22
  """
23
23
  Finds the currently selected tab by its label.
24
24
 
@@ -30,7 +30,7 @@ class TabUtils:
30
30
  The Selenium WebElement for the selected tab.
31
31
 
32
32
  Example:
33
- TabUtils.find_selected_tab(wait, "Settings")
33
+ TabUtils.findSelectedTab(wait, "Settings")
34
34
  """
35
35
  # This method locates a tab that is currently selected and contains the specified label.
36
36
 
@@ -44,7 +44,7 @@ class TabUtils:
44
44
  return component
45
45
 
46
46
  @staticmethod
47
- def select_tab(wait, label):
47
+ def selectInactiveTab(wait, label):
48
48
  """
49
49
  Selects a tab by its label.
50
50
 
@@ -53,7 +53,7 @@ class TabUtils:
53
53
  label: The visible text label of the tab to select.
54
54
 
55
55
  Example:
56
- TabUtils.select_tab(wait, "Settings")
56
+ TabUtils.selectInactiveTab(wait, "Settings")
57
57
  """
58
58
  # This method locates a tab that contains a label with the specified text.
59
59
 
@@ -11,12 +11,12 @@ class TableUtils:
11
11
 
12
12
  # Find a table using a column name
13
13
  from robo_appian.components.TableUtils import TableUtils
14
- table = TableUtils.findTableUsingColumnName(wait, "Status")
14
+ table = TableUtils.findTableByColumnName(wait, "Status")
15
15
 
16
16
  """
17
17
 
18
18
  @staticmethod
19
- def findTableUsingColumnName(wait: WebDriverWait, columnName: str):
19
+ def findTableByColumnName(wait: WebDriverWait, columnName: str):
20
20
  """
21
21
  Finds a table component that contains a column with the specified name.
22
22
 
@@ -28,7 +28,7 @@ class TableUtils:
28
28
  The Selenium WebElement for the table component.
29
29
 
30
30
  Example:
31
- table = TableUtils.findTableUsingColumnName(wait, "Status")
31
+ table = TableUtils.findTableByColumnName(wait, "Status")
32
32
 
33
33
  """
34
34
  # This method locates a table that contains a header cell with the specified column name.
@@ -49,89 +49,6 @@ class TableUtils:
49
49
  )
50
50
  return component
51
51
 
52
- @staticmethod
53
- def clickOnLinkUsingHoverText(wait, columnName, rowNumber, hoverText):
54
- """
55
- Clicks on a link in a table cell identified by its column name, row number, and the hover text of the link.
56
-
57
- Parameters:
58
- wait: Selenium WebDriverWait instance.
59
- columnName: The name of the column where the link is located.
60
- rowNumber: The row number (0-based index) where the link is located.
61
- hoverText: The text that appears when hovering over the link.
62
-
63
- Example:
64
- TableUtils.clickOnLinkUsingHoverText(wait, "Status", 2, "View Details")
65
-
66
- """
67
-
68
- # This method locates a link within a specific table cell based on the column name and row number.
69
- # It constructs an XPath that targets the table cell containing the link with the specified hover text.
70
- # The XPath first identifies the table by the column name, then finds the specific row and cell,
71
- # and finally looks for the link with the specified hover text.
72
-
73
- xpath = f".//table[./thead/tr/th[@abbr='{columnName}']]/tbody/tr[@data-dnd-name='row {rowNumber + 1}']/td[not (@data-empty-grid-message)]/div/p/a[./span[text()='{hoverText}']]"
74
- # xpath=f".//table[./thead/tr/th/div[text()='{columnName}']][1]/tbody/tr[@data-dnd-name='row {rowNumber}']/td/div/p/a[./span[text()='{hoverText}']]"
75
- try:
76
- component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
77
- except TimeoutError as e:
78
- raise TimeoutError(
79
- f"Could not find link with hover text '{hoverText}' in column '{columnName}', row {rowNumber}: {e}"
80
- )
81
- except Exception as e:
82
- raise RuntimeError(
83
- f"Could not find link with hover text '{hoverText}' in column '{columnName}', row {rowNumber}: {e}"
84
- )
85
- component.click()
86
-
87
- @staticmethod
88
- def clickOnButtonUsingHoverText(wait, columnName, rowNumber, hoverText):
89
- """
90
- Clicks on a button in a table cell identified by its column name, row number, and the hover text of the button.
91
-
92
- Parameters:
93
- wait: Selenium WebDriverWait instance.
94
- columnName: The name of the column where the button is located.
95
- rowNumber: The row number (0-based index) where the button is located.
96
- hoverText: The text that appears when hovering over the button.
97
-
98
- Example:
99
- TableUtils.clickOnButtonUsingHoverText(wait, "Actions", 2, "Delete")
100
-
101
- """
102
- # This method locates a button within a specific table cell based on the column name and row number.
103
- # It constructs an XPath that targets the table cell containing the button with the specified hover text.
104
- # The XPath first identifies the table by the column name, then finds the specific row and cell,
105
- # and finally looks for the button with the specified hover text.
106
-
107
- # TODO rowNumber = rowNumber + 1 # Adjusting for 1-based index in XPath
108
-
109
- xpath = f".//table[./thead/tr/th[@abbr='{columnName}']]/tbody/tr[@data-dnd-name='row {rowNumber}']/td[not (@data-empty-grid-message)]"
110
- try:
111
- component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
112
- except TimeoutError as e:
113
- raise TimeoutError(
114
- f"Could not find button with hover text '{hoverText}' in column '{columnName}', row {rowNumber}: {e}"
115
- )
116
- except Exception as e:
117
- raise RuntimeError(
118
- f"Could not find button with hover text '{hoverText}' in column '{columnName}', row {rowNumber}: {e}"
119
- )
120
- component.click()
121
-
122
- xpath = f".//table[./thead/tr/th[@abbr='{columnName}']]/tbody/tr[@data-dnd-name='row {rowNumber}']/td[not (@data-empty-grid-message)]/div/div/button[./span[text()='{hoverText}']]"
123
- try:
124
- component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
125
- except TimeoutError as e:
126
- raise TimeoutError(
127
- f"Could not find button with hover text '{hoverText}' in column '{columnName}', row {rowNumber}: {e}"
128
- )
129
- except Exception as e:
130
- raise RuntimeError(
131
- f"Could not find button with hover text '{hoverText}' in column '{columnName}', row {rowNumber}: {e}"
132
- )
133
- component.click()
134
-
135
52
  @staticmethod
136
53
  def rowCount(tableObject):
137
54
  """
@@ -155,7 +72,7 @@ class TableUtils:
155
72
  return len(rows)
156
73
 
157
74
  @staticmethod
158
- def findColumNumberUsingColumnName(tableObject, columnName):
75
+ def findColumNumberByColumnName(tableObject, columnName):
159
76
  """
160
77
  Finds the column number in a table based on the column name.
161
78
 
@@ -167,7 +84,7 @@ class TableUtils:
167
84
  The index of the column (0-based).
168
85
 
169
86
  Example:
170
- column_number = TableUtils.findColumNumberUsingColumnName(table, "Status")
87
+ column_number = TableUtils.findColumNumberByColumnName(table, "Status")
171
88
 
172
89
  """
173
90
  # This method locates the column header cell with the specified column name
@@ -199,7 +116,7 @@ class TableUtils:
199
116
  return int(data[1])
200
117
 
201
118
  @staticmethod
202
- def find_component_from_tabele_cell(wait, rowNumber, columnName):
119
+ def findComponentFromTableCell(wait, rowNumber, columnName):
203
120
  """
204
121
  Finds a component within a specific table cell based on the row number and column name.
205
122
 
@@ -212,17 +129,15 @@ class TableUtils:
212
129
  The Selenium WebElement for the component within the specified table cell.
213
130
 
214
131
  Example:
215
- component = TableUtils.find_component_from_tabele_cell(wait, 2, "Status")
132
+ component = TableUtils.findComponentFromTableCell(wait, 2, "Status")
216
133
 
217
134
  """
218
135
  # This method locates a specific component within a table cell based on the provided row number
219
136
  # and column name. It constructs an XPath that targets the table cell containing the specified column
220
137
  # and row, and then retrieves the component within that cell.
221
138
 
222
- tableObject = TableUtils.findTableUsingColumnName(wait, columnName)
223
- columnNumber = TableUtils.findColumNumberUsingColumnName(
224
- tableObject, columnName
225
- )
139
+ tableObject = TableUtils.findTableByColumnName(wait, columnName)
140
+ columnNumber = TableUtils.findColumNumberByColumnName(tableObject, columnName)
226
141
  # xpath=f'./tbody/tr[@data-dnd-name="row {rowNumber+1}"]/td[not (@data-empty-grid-message)][{columnNumber}]'
227
142
  # component = tableObject.find_elements(By.XPATH, xpath)
228
143
  rowNumber = rowNumber + 1
@@ -1,6 +1,5 @@
1
1
  from robo_appian.components.ButtonUtils import ButtonUtils
2
2
  from selenium.webdriver.support.ui import WebDriverWait
3
- from robo_appian.utils.ComponentUtils import ComponentUtils
4
3
  from robo_appian.components.DateUtils import DateUtils
5
4
  from robo_appian.components.DropdownUtils import DropdownUtils
6
5
  from robo_appian.components.InputUtils import InputUtils
@@ -8,6 +7,7 @@ from robo_appian.components.LabelUtils import LabelUtils
8
7
  from robo_appian.components.LinkUtils import LinkUtils
9
8
  from robo_appian.components.TabUtils import TabUtils
10
9
  from robo_appian.components.SearchInputUtils import SearchInputUtils
10
+ from robo_appian.components.SearchDropdownUtils import SearchDropdownUtils
11
11
 
12
12
 
13
13
  class ComponentDriver:
@@ -35,7 +35,6 @@ class ComponentDriver:
35
35
  # This method executes an action on a specified component type based on the provided parameters.
36
36
 
37
37
  match type:
38
-
39
38
  case "Date":
40
39
  match action:
41
40
  case "Set Value":
@@ -51,9 +50,7 @@ class ComponentDriver:
51
50
  case "Search Input Text":
52
51
  match action:
53
52
  case "Select":
54
- SearchInputUtils.selectSearchDropdownByLabelText(
55
- wait, label, value
56
- )
53
+ SearchInputUtils.selectSearchDropdownByLabelText(wait, label, value)
57
54
  case _:
58
55
  raise ValueError(f"Unsupported action for {type}: {action}")
59
56
  case "Label":
@@ -77,7 +74,7 @@ class ComponentDriver:
77
74
  case "Search Drop Down":
78
75
  match action:
79
76
  case "Select":
80
- DropdownUtils.selectSearchDropdownValueByLabelText(wait, label, value)
77
+ SearchDropdownUtils.selectSearchDropdownValueByLabelText(wait, label, value)
81
78
  case _:
82
79
  raise ValueError(f"Unsupported action for {type}: {action}")
83
80
  case "Button":
@@ -89,7 +86,7 @@ class ComponentDriver:
89
86
  case "Tab":
90
87
  match action:
91
88
  case "Find":
92
- TabUtils.find_selected_tab(wait, label)
89
+ TabUtils.findSelectedTab(wait, label)
93
90
  case _:
94
91
  raise ValueError(f"Unsupported action for {type}: {action}")
95
92
  case _:
@@ -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
@@ -203,7 +206,7 @@ class ComponentUtils:
203
206
  Raises:
204
207
  Exception: If no components are found.
205
208
  """
206
-
209
+
207
210
  # Wait for at least one element to be present
208
211
  wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
209
212
 
@@ -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