robo_appian 0.0.27__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.
@@ -0,0 +1,161 @@
1
+ from robo_appian.utils.ComponentUtils import ComponentUtils
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
+
7
+ class InputUtils:
8
+ """
9
+ Utility class for interacting with input components in Appian UI.
10
+ Usage Example:
11
+ from robo_appian.components.InputUtils import InputUtils
12
+
13
+ # Set a value in an input component by its label
14
+ InputUtils.setValueByLabelText(wait, "Username", "test_user")
15
+
16
+ # Set a value in an input component by its ID
17
+ InputUtils.setValueById(wait, "inputComponentId", "test_value")
18
+ """
19
+
20
+ @staticmethod
21
+ def __findComponentByPartialLabel(wait: WebDriverWait, label: str):
22
+ """
23
+ Finds an input component by its label text, allowing for partial matches.
24
+
25
+ Parameters:
26
+ wait: Selenium WebDriverWait instance.
27
+ label: The visible text label of the input component, allowing for partial matches.
28
+
29
+ Returns:
30
+ A Selenium WebElement representing the input component.
31
+
32
+ Example:
33
+ InputUtils.__findInputComponentByPartialLabel(wait, "User")
34
+ """
35
+
36
+ xpath = f'.//div/label[contains(normalize-space(.), "{label}")]'
37
+ label_component = ComponentUtils.waitForComponentToBeVisibleByXpath(wait, xpath)
38
+
39
+ input_id = label_component.get_attribute("for")
40
+ if input_id is None:
41
+ raise ValueError(f"Label component with text '{label}' does not have a 'for' attribute.")
42
+
43
+ component = ComponentUtils.findComponentById(wait, input_id)
44
+ return component
45
+
46
+ @staticmethod
47
+ def __findComponentByLabel(wait: WebDriverWait, label: str):
48
+ """Finds a component by its label text.
49
+ Parameters:
50
+ wait: Selenium WebDriverWait instance.
51
+ label: The visible text label of the input component.
52
+
53
+ Returns:
54
+ A Selenium WebElement representing the input component.
55
+
56
+ Example:
57
+ InputUtils.__findComponentByLabel(wait, "Username")
58
+ """
59
+
60
+ xpath = f'.//div/label[normalize-space(.)="{label}"]'
61
+ label_component = ComponentUtils.waitForComponentToBeVisibleByXpath(wait, xpath)
62
+ input_id = label_component.get_attribute("for")
63
+ if input_id is None:
64
+ raise ValueError(f"Label component with text '{label}' does not have a 'for' attribute.")
65
+
66
+ component = ComponentUtils.findComponentById(wait, input_id)
67
+ return component
68
+
69
+ @staticmethod
70
+ def _setValueByComponent(wait: WebDriverWait, component: WebElement, value: str):
71
+ """
72
+ Sets a value in an input component.
73
+ Parameters:
74
+ component: The Selenium WebElement for the input component.
75
+ value: The value to set in the input field.
76
+ Returns:
77
+ The Selenium WebElement for the input component after setting the value.
78
+ Example:
79
+ InputUtils._setValueByComponent(component, "test_value")
80
+ """
81
+ wait.until(EC.element_to_be_clickable(component))
82
+ component.clear()
83
+ component.send_keys(value)
84
+ return component
85
+
86
+ @staticmethod
87
+ def setValueByPartialLabelText(wait: WebDriverWait, label: str, value: str):
88
+ """
89
+ Sets a value in an input component identified by its partial label text.
90
+
91
+ Parameters:
92
+ wait: Selenium WebDriverWait instance.
93
+ label: The visible text label of the input component (partial match).
94
+ value: The value to set in the input field.
95
+
96
+ Returns:
97
+ None
98
+ """
99
+ component = InputUtils.__findComponentByPartialLabel(wait, label)
100
+ InputUtils._setValueByComponent(wait, component, value)
101
+
102
+ @staticmethod
103
+ def setValueByLabelText(wait: WebDriverWait, label: str, value: str):
104
+ """
105
+ Sets a value in an input component identified by its label text.
106
+
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
+
112
+ Returns:
113
+ None
114
+
115
+ Example:
116
+ InputUtils.setValueByLabelText(wait, "Username", "test_user")
117
+ """
118
+ component = InputUtils.__findComponentByLabel(wait, label)
119
+ InputUtils._setValueByComponent(wait, component, value)
120
+
121
+ @staticmethod
122
+ def setValueById(wait: WebDriverWait, id: str, value: str):
123
+ """
124
+ Sets a value in an input component identified by its ID.
125
+
126
+ Parameters:
127
+ wait: Selenium WebDriverWait instance.
128
+ id: The ID of the input component.
129
+ value: The value to set in the input field.
130
+
131
+ Returns:
132
+ The Selenium WebElement for the input component after setting the value.
133
+
134
+ Example:
135
+ InputUtils.setValueById(wait, "inputComponentId", "test_value")
136
+ """
137
+ # try:
138
+ # component = wait.until(EC.element_to_be_clickable((By.ID, component_id)))
139
+ # except Exception as e:
140
+ # raise Exception(f"Timeout or error finding input component with id '{component_id}': {e}")
141
+ component = ComponentUtils.findComponentById(wait, id)
142
+ InputUtils._setValueByComponent(wait, component, value)
143
+
144
+ @staticmethod
145
+ def setValueByPlaceholderText(wait: WebDriverWait, text: str, value: str):
146
+ """Sets a value in an input component identified by its placeholder text.
147
+
148
+ Parameters:
149
+ wait: Selenium WebDriverWait instance.
150
+ text: The placeholder text of the input component.
151
+ value: The value to set in the input field.
152
+
153
+ Returns:
154
+ None
155
+
156
+ Example:
157
+ InputUtils.setValueByPlaceholderText(wait, "Enter your name", "John Doe")
158
+ """
159
+ xpath = f'.//input[@placeholder="{text}"]'
160
+ component = ComponentUtils.waitForComponentToBeVisibleByXpath(wait, xpath)
161
+ InputUtils._setValueByComponent(wait, component, value)
@@ -0,0 +1,67 @@
1
+ from selenium.webdriver.support import expected_conditions as EC
2
+ from selenium.webdriver.support.ui import WebDriverWait
3
+ from selenium.webdriver.common.by import By
4
+ from robo_appian.utils.ComponentUtils import ComponentUtils
5
+
6
+
7
+ class LabelUtils:
8
+ """
9
+ Utility class for interacting with label components in Appian UI.
10
+ Usage Example:
11
+ # Find a label by its text
12
+ component = LabelUtils._findByLabelText(wait, "Submit")
13
+ # Click a label by its text
14
+ LabelUtils.clickByLabelText(wait, "Submit")
15
+ """
16
+
17
+ @staticmethod
18
+ def __findByLabelText(wait: WebDriverWait, label: str):
19
+ """
20
+ Finds a label element by its text.
21
+
22
+ :param wait: Selenium WebDriverWait instance.
23
+ :param label: The text of the label to find.
24
+ :return: WebElement representing the label.
25
+ Example:
26
+ component = LabelUtils._findByLabelText(wait, "Submit")
27
+ """
28
+ xpath = f'//*[normalize-space(translate(., "\u00a0", " "))="{label}"]'
29
+ try:
30
+ # component = wait.until(EC.visibility_of_element_located((By.XPATH, xpath)))
31
+ component = ComponentUtils.waitForComponentToBeVisibleByXpath(wait, xpath)
32
+ except Exception as e:
33
+ raise Exception(f"Label with text '{label}' not found.") from e
34
+
35
+ return component
36
+
37
+ @staticmethod
38
+ def clickByLabelText(wait: WebDriverWait, label: str):
39
+ """
40
+ Clicks a label element identified by its text.
41
+
42
+ :param wait: Selenium WebDriverWait instance.
43
+ :param label: The text of the label to click.
44
+ Example:
45
+ LabelUtils.clickByLabelText(wait, "Submit")
46
+ """
47
+ component = LabelUtils.__findByLabelText(wait, label)
48
+ wait.until(EC.element_to_be_clickable(component))
49
+ component.click()
50
+
51
+ @staticmethod
52
+ def isLabelExists(wait: WebDriverWait, label: str):
53
+ try:
54
+ LabelUtils.__findByLabelText(wait, label)
55
+ except Exception:
56
+ return False
57
+ return True
58
+
59
+ @staticmethod
60
+ def isLabelExistsAfterLoad(wait: WebDriverWait, label: str):
61
+ try:
62
+ xpath = f'.//*[normalize-space(translate(., "\u00a0", " "))="{label}"]'
63
+ wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
64
+ wait.until(EC.visibility_of_element_located((By.XPATH, xpath)))
65
+ except Exception:
66
+ return False
67
+ return True
@@ -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 LinkUtils:
7
+ """
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
12
+ from robo_appian.components.LinkUtils import LinkUtils
13
+
14
+ driver = webdriver.Chrome()
15
+ wait = WebDriverWait(driver, 10)
16
+ LinkUtils.click(wait, "Learn More")
17
+ driver.quit()
18
+ """
19
+
20
+ @staticmethod
21
+ def find(wait: WebDriverWait, label: str):
22
+ # xpath = f'.//a[normalize-space(.)="{label}"]'
23
+ xpath = f'.//a[normalize-space(.)="{label}" and not(ancestor::*[@aria-hidden="true"])]'
24
+ try:
25
+ component = wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
26
+ except Exception as e:
27
+ raise Exception(f"Could not find clickable link with label '{label}': {e}")
28
+ return component
29
+
30
+ @staticmethod
31
+ def click(wait: WebDriverWait, label: str):
32
+ """
33
+ Clicks a link identified by its label.
34
+
35
+ Parameters:
36
+ wait: Selenium WebDriverWait instance.
37
+ label: The visible text label of the link.
38
+
39
+ Example:
40
+ LinkUtils.click(wait, "Learn More")
41
+ """
42
+
43
+ component = LinkUtils.find(wait, label)
44
+ wait.until(EC.element_to_be_clickable(component))
45
+ component.click()
46
+ return component
@@ -0,0 +1,91 @@
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 selenium.webdriver.remote.webelement import WebElement
5
+ from robo_appian.components.InputUtils import InputUtils
6
+
7
+
8
+ class SearchDropdownUtils:
9
+ """
10
+ Utility class for interacting with search dropdown components in Appian UI.
11
+ Usage Example:
12
+ # Select a value from a search dropdown
13
+ from robo_appian.components.SearchDropdownUtils import SearchDropdownUtils
14
+ SearchDropdownUtils.selectSearchDropdownValueByLabelText(wait, "Status", "Approved")
15
+ """
16
+
17
+ @staticmethod
18
+ def __selectSearchDropdownValueByDropdownId(wait: WebDriverWait, component_id: str, value: str):
19
+ if not component_id:
20
+ raise ValueError("Invalid component_id provided.")
21
+
22
+ input_component_id = str(component_id) + "_searchInput"
23
+ try:
24
+ wait.until(EC.presence_of_element_located((By.ID, input_component_id)))
25
+ input_component = wait.until(EC.element_to_be_clickable((By.ID, input_component_id)))
26
+ except Exception as e:
27
+ raise Exception(f"Failed to locate or click input component with ID '{input_component_id}': {e}")
28
+ InputUtils._setValueByComponent(wait, input_component, value)
29
+
30
+ dropdown_option_id = str(component_id) + "_list"
31
+
32
+ xpath = f'.//ul[@id="{dropdown_option_id}"]/li[./div[normalize-space(.)="{value}"]][1]'
33
+ try:
34
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
35
+ except Exception as e:
36
+ raise Exception(f"Failed to locate or click dropdown option with XPath '{xpath}': {e}")
37
+ component.click()
38
+
39
+ @staticmethod
40
+ def __selectSearchDropdownValueByPartialLabelText(wait: WebDriverWait, label: str, value: str):
41
+ xpath = f'.//div[./div/span[contains(normalize-space(.), "{label}")]]/div/div/div/div[@role="combobox" and not(@aria-disabled="true")]'
42
+ try:
43
+ combobox = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
44
+ except Exception as e:
45
+ raise Exception(f"Failed to locate or click dropdown component with XPath '{xpath}': {e}")
46
+
47
+ SearchDropdownUtils._selectSearchDropdownValueByComboboxComponent(wait, combobox, value)
48
+
49
+ @staticmethod
50
+ def __selectSearchDropdownValueByLabelText(wait: WebDriverWait, label: str, value: str):
51
+ xpath = (
52
+ f'.//div[./div/span[normalize-space(.)="{label}"]]/div/div/div/div[@role="combobox" and not(@aria-disabled="true")]'
53
+ )
54
+ try:
55
+ combobox = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
56
+ except Exception as e:
57
+ raise Exception(f"Failed to locate or click dropdown component with XPath '{xpath}': {e}")
58
+ SearchDropdownUtils._selectSearchDropdownValueByComboboxComponent(wait, combobox, value)
59
+
60
+ @staticmethod
61
+ def _selectSearchDropdownValueByComboboxComponent(wait: WebDriverWait, combobox: WebElement, value: str):
62
+ id = combobox.get_attribute("id")
63
+ if id is not None:
64
+ component_id = id.rsplit("_value", 1)[0]
65
+ else:
66
+ raise Exception("Combobox element does not have an 'id' attribute.")
67
+
68
+ wait.until(EC.element_to_be_clickable(combobox))
69
+ combobox.click()
70
+
71
+ SearchDropdownUtils.__selectSearchDropdownValueByDropdownId(wait, component_id, value)
72
+
73
+ @staticmethod
74
+ def selectSearchDropdownValueByLabelText(wait: WebDriverWait, dropdown_label: str, value: str):
75
+ """Selects a value from a search dropdown by label text.
76
+ Args:
77
+ wait (WebDriverWait): The WebDriverWait instance to use for waiting.
78
+ dropdown_label (str): The label text of the dropdown.
79
+ value (str): The value to select from the dropdown.
80
+ """
81
+ SearchDropdownUtils.__selectSearchDropdownValueByLabelText(wait, dropdown_label, value)
82
+
83
+ @staticmethod
84
+ def selectSearchDropdownValueByPartialLabelText(wait: WebDriverWait, dropdown_label: str, value: str):
85
+ """Selects a value from a search dropdown by partial label text.
86
+ Args:
87
+ wait (WebDriverWait): The WebDriverWait instance to use for waiting.
88
+ dropdown_label (str): The label text of the dropdown.
89
+ value (str): The value to select from the dropdown.
90
+ """
91
+ SearchDropdownUtils.__selectSearchDropdownValueByPartialLabelText(wait, dropdown_label, value)
@@ -0,0 +1,63 @@
1
+ from selenium.webdriver.support.ui import WebDriverWait
2
+ from selenium.webdriver.common.by import By
3
+ from selenium.webdriver.support import expected_conditions as EC
4
+ from robo_appian.components.InputUtils import InputUtils
5
+ from robo_appian.utils.ComponentUtils import ComponentUtils
6
+
7
+
8
+ class SearchInputUtils:
9
+ """
10
+ Utility class for handling search input operations in Selenium WebDriver.
11
+ Example usage:
12
+ from selenium import webdriver
13
+ from selenium.webdriver.support.ui import WebDriverWait
14
+ from robo_appian.components.SearchInputUtils import SearchInputUtils
15
+
16
+ driver = webdriver.Chrome()
17
+ wait = WebDriverWait(driver, 10)
18
+ SearchInputUtils.selectSearchDropdownByLabelText(wait, "Search Label", "Value")
19
+ driver.quit()
20
+ """
21
+
22
+ @staticmethod
23
+ def __findSearchInputComponentsByLabelPathAndSelectValue(wait: WebDriverWait, xpath: str, value: str):
24
+ search_input_components = ComponentUtils.findComponentsByXPath(wait, xpath)
25
+ input_components = []
26
+ for search_input_component in search_input_components:
27
+ attribute: str = "aria-controls"
28
+ dropdown_list_id = search_input_component.get_attribute(attribute)
29
+ if dropdown_list_id:
30
+ InputUtils._setValueByComponent(wait, search_input_component, value)
31
+ xpath = f'.//ul[@id="{dropdown_list_id}" and @role="listbox" ]/li[@role="option" and @tabindex="-1" and ./div/div/div/div/div/div/p[normalize-space(.)="{value}"][1]]'
32
+ try:
33
+ drop_down_item = wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
34
+ drop_down_item = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
35
+ except Exception as e:
36
+ raise Exception(
37
+ f"Dropdown item with value '{value}' not found for component '{search_input_component.text}'."
38
+ ) from e
39
+ drop_down_item.click()
40
+ else:
41
+ raise ValueError(
42
+ f"Search input component with label '{search_input_component.text}' does not have 'aria-controls' attribute."
43
+ )
44
+
45
+ return input_components
46
+
47
+ @staticmethod
48
+ def __selectSearchInputComponentsByPartialLabelText(wait: WebDriverWait, label: str, value: str):
49
+ xpath = f".//div[./div/span[contains(normalize-space(.)='{label}']]/div/div/div/input[@role='combobox']"
50
+ SearchInputUtils.__findSearchInputComponentsByLabelPathAndSelectValue(wait, xpath, value)
51
+
52
+ @staticmethod
53
+ def __selectSearchInputComponentsByLabelText(wait: WebDriverWait, label: str, value: str):
54
+ xpath = f".//div[./div/span[text()='{label}']]/div/div/div/input[@role='combobox']"
55
+ SearchInputUtils.__findSearchInputComponentsByLabelPathAndSelectValue(wait, xpath, value)
56
+
57
+ @staticmethod
58
+ def selectSearchDropdownByLabelText(wait: WebDriverWait, label: str, value: str):
59
+ SearchInputUtils.__selectSearchInputComponentsByLabelText(wait, label, value)
60
+
61
+ @staticmethod
62
+ def selectSearchDropdownByPartialLabelText(wait: WebDriverWait, label: str, value: str):
63
+ SearchInputUtils.__selectSearchInputComponentsByPartialLabelText(wait, label, value)
@@ -0,0 +1,60 @@
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 robo_appian.utils.ComponentUtils import ComponentUtils
6
+
7
+
8
+ class TabUtils:
9
+ """
10
+ Utility class for handling tab components in a web application using Selenium.
11
+ Example usage:
12
+ from selenium import webdriver
13
+ from selenium.webdriver.support.ui import WebDriverWait
14
+ from robo_appian.components.TabUtils import TabUtils
15
+
16
+ driver = webdriver.Chrome()
17
+ wait = WebDriverWait(driver, 10)
18
+
19
+ # Find a selected tab by its label
20
+ selected_tab = TabUtils.findSelectedTabByLabelText(wait, "Tab Label")
21
+
22
+ # Select an inactive tab by its label
23
+ TabUtils.selectTabByLabelText(wait, "Inactive Tab Label")
24
+
25
+ driver.quit()
26
+ """
27
+ @staticmethod
28
+ def __click(wait: WebDriverWait, component: WebElement, label: str):
29
+ try:
30
+ component = wait.until(EC.element_to_be_clickable(component))
31
+ component.click()
32
+ except Exception:
33
+ raise Exception(f"Tab with label '{label}' is not clickable.")
34
+
35
+ @staticmethod
36
+ def findTabByLabelText(wait: WebDriverWait, label: str) -> WebElement:
37
+ xpath = f'//div/div[@role="link" ]/div/div/div/div/div/p[normalize-space(.)="{label}"]'
38
+ try:
39
+ component = wait.until(EC.visibility_of_element_located((By.XPATH, xpath)))
40
+ except Exception:
41
+ raise Exception(f"Tab with label '{label}' not found.")
42
+ return component
43
+
44
+ @staticmethod
45
+ def selectTabByLabelText(wait: WebDriverWait, label: str):
46
+ component = TabUtils.findTabByLabelText(wait, label)
47
+ TabUtils.__click(wait, component, label)
48
+
49
+ @staticmethod
50
+ def checkTabSelectedByLabelText(wait: WebDriverWait, label: str):
51
+ component = TabUtils.findTabByLabelText(wait, label)
52
+
53
+ select_text = "Selected Tab."
54
+ xpath = f'./span[normalize-space(.)="{select_text}"]'
55
+ try:
56
+ component = ComponentUtils.findChildComponentByXpath(wait, component, xpath)
57
+ except Exception:
58
+ return False
59
+
60
+ return True
@@ -0,0 +1,149 @@
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 robo_appian.utils.ComponentUtils import ComponentUtils
5
+
6
+
7
+ class TableUtils:
8
+ """
9
+ Utility class for handling table operations in Selenium WebDriver.
10
+ Example usage:
11
+ from selenium import webdriver
12
+ from selenium.webdriver.support.ui import WebDriverWait
13
+ from robo_appian.components.TableUtils import TableUtils
14
+
15
+ driver = webdriver.Chrome()
16
+ wait = WebDriverWait(driver, 10)
17
+ table = TableUtils.findTableByColumnName(wait, "Status")
18
+ row_count = TableUtils.rowCount(table)
19
+ component = TableUtils.findComponentFromTableCell(wait, 1, "Status")
20
+ driver.quit()
21
+
22
+ """
23
+
24
+ @staticmethod
25
+ def rowCount(tableObject):
26
+ """
27
+ Counts the number of rows in a table.
28
+
29
+ :param tableObject: The Selenium WebElement representing the table.
30
+ :return: The number of rows in the table.
31
+ Example:
32
+ row_count = TableUtils.rowCount(table)
33
+ """
34
+
35
+ xpath = "./tbody/tr[./td[not (@data-empty-grid-message)]]"
36
+ try:
37
+ rows = tableObject.find_elements(By.XPATH, xpath)
38
+ except Exception as e:
39
+ raise Exception(f"Could not count rows in table: {e}")
40
+ return len(rows)
41
+
42
+ @staticmethod
43
+ def __findColumNumberByColumnName(tableObject, columnName):
44
+ """
45
+ Finds the column number in a table by its column name.
46
+
47
+ :param tableObject: The Selenium WebElement representing the table.
48
+ :param columnName: The name of the column to search for.
49
+ :return: The index of the column (0-based).
50
+ Example:
51
+ column_number = TableUtils.__findColumNumberByColumnName(table, "Status")
52
+ """
53
+
54
+ xpath = f'./thead/tr/th[@scope="col" and @abbr="{columnName}"]'
55
+ component = tableObject.find_element(By.XPATH, xpath)
56
+
57
+ if component is None:
58
+ raise ValueError(f"Could not find a column with abbr '{columnName}' in the table header.")
59
+
60
+ class_string = component.get_attribute("class")
61
+ partial_string = "headCell_"
62
+ words = class_string.split()
63
+ selected_word = None
64
+
65
+ for word in words:
66
+ if partial_string in word:
67
+ selected_word = word
68
+
69
+ if selected_word is None:
70
+ raise ValueError(f"Could not find a class containing '{partial_string}' in the column header for '{columnName}'.")
71
+
72
+ data = selected_word.split("_")
73
+ return int(data[1])
74
+
75
+ @staticmethod
76
+ def __findRowByColumnNameAndRowNumber(wait, rowNumber, columnName):
77
+ # xpath = f'.//table[./thead/tr/th/div[normalize-space(.)="{columnName}"] ]/tbody/tr[@data-dnd-name="row {rowNumber + 1}"]'
78
+ xpath = f'.//table[./thead/tr/th[@abbr="{columnName}"]]/tbody/tr[@data-dnd-name="row {rowNumber + 1}" and not(ancestor::*[@aria-hidden="true"])]'
79
+ row = wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
80
+ return row
81
+
82
+ @staticmethod
83
+ def findComponentFromTableCell(wait, rowNumber, columnName):
84
+ """
85
+ Finds a component within a specific cell of a table by row number and column name.
86
+
87
+ :param wait: Selenium WebDriverWait instance.
88
+ :param rowNumber: The row number (0-based index).
89
+ :param columnName: The name of the column to search in.
90
+ :return: WebElement representing the component in the specified cell.
91
+ Example:
92
+ component = TableUtils.findComponentFromTableCell(wait, 1, "Status")
93
+ """
94
+
95
+ tableObject = TableUtils.findTableByColumnName(wait, columnName)
96
+ columnNumber = TableUtils.__findColumNumberByColumnName(tableObject, columnName)
97
+ rowNumber = rowNumber + 1
98
+ columnNumber = columnNumber + 1
99
+ xpath = f'.//table[./thead/tr/th[@abbr="{columnName}"]]/tbody/tr[@data-dnd-name="row {rowNumber}"]/td[not (@data-empty-grid-message)][{columnNumber}]/*'
100
+ try:
101
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
102
+ except Exception as e:
103
+ raise Exception(f"Could not find component in cell at row {rowNumber}, column '{columnName}': {e}")
104
+ return component
105
+
106
+ @staticmethod
107
+ def selectRowFromTableByColumnNameAndRowNumber(wait, rowNumber, columnName):
108
+ row = TableUtils.__findRowByColumnNameAndRowNumber(wait, rowNumber, columnName)
109
+ row = wait.until(EC.element_to_be_clickable(row))
110
+ row.click()
111
+
112
+ @staticmethod
113
+ def findComponentByColumnNameAndRowNumber(wait, rowNumber, columnName):
114
+ # xpath = f'.//table/thead/tr/th[./div[normalize-space(.)="{columnName}"]]'
115
+ xpath = f'.//table/thead/tr/th[@abbr="{columnName}" and not(ancestor::*[@aria-hidden="true"]) ]'
116
+ column = wait.until(EC.visibility_of_element_located((By.XPATH, xpath)))
117
+ id = column.get_attribute("id")
118
+ parts = id.rsplit("_", 1)
119
+ columnNumber = int(parts[-1])
120
+
121
+ tableRow = TableUtils.__findRowByColumnNameAndRowNumber(wait, rowNumber, columnName)
122
+ xpath = f"./td[{columnNumber + 1}]/*"
123
+ component = ComponentUtils.findChildComponentByXpath(wait, tableRow, xpath)
124
+ component = wait.until(EC.element_to_be_clickable(component))
125
+ return component
126
+
127
+ @staticmethod
128
+ def findTableByColumnName(wait: WebDriverWait, columnName: str):
129
+ """
130
+ Finds a table component by its column name.
131
+
132
+ :param wait: Selenium WebDriverWait instance.
133
+ :param columnName: The name of the column to search for.
134
+ :return: WebElement representing the table.
135
+ Example:
136
+ component = TableUtils.findTableByColumnName(wait, "Status")
137
+ """
138
+
139
+ xpath = f'.//table[./thead/tr/th[@abbr="{columnName}"]]'
140
+ try:
141
+ component = wait.until(EC.visibility_of_element_located((By.XPATH, xpath)))
142
+ except Exception as e:
143
+ raise Exception(f"Could not find table with column name '{columnName}': {e}")
144
+
145
+ try:
146
+ component = wait.until(EC.element_to_be_clickable(component))
147
+ except Exception as e:
148
+ raise Exception(f"Table found by column name '{columnName}' is not clickable: {e}")
149
+ return component
@@ -0,0 +1,22 @@
1
+ from robo_appian.components.ButtonUtils import ButtonUtils
2
+ from robo_appian.components.DateUtils import DateUtils
3
+ from robo_appian.components.DropdownUtils import DropdownUtils
4
+ from robo_appian.components.InputUtils import InputUtils
5
+ from robo_appian.components.LabelUtils import LabelUtils
6
+ from robo_appian.components.LinkUtils import LinkUtils
7
+ from robo_appian.components.SearchDropdownUtils import SearchDropdownUtils
8
+ from robo_appian.components.TableUtils import TableUtils
9
+ from robo_appian.components.TabUtils import TabUtils
10
+
11
+
12
+ __all__ = [
13
+ "ButtonUtils",
14
+ "DateUtils",
15
+ "DropdownUtils",
16
+ "InputUtils",
17
+ "LabelUtils",
18
+ "LinkUtils",
19
+ "SearchDropdownUtils",
20
+ "TableUtils",
21
+ "TabUtils",
22
+ ]