robo_appian 0.0.10__py3-none-any.whl → 0.0.12__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.

@@ -5,67 +5,51 @@ from selenium.webdriver.support.ui import WebDriverWait
5
5
 
6
6
  class ButtonUtils:
7
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
8
+ Utility class for interacting with button components in Appian UI.
9
+ Usage Example:
10
+ # Click a button by its label
13
11
  from robo_appian.components.ButtonUtils import ButtonUtils
14
-
15
- wait = WebDriverWait(driver, 10)
16
- ButtonUtils.click(wait, "Login")
17
-
12
+ ButtonUtils.clickByLabelText(wait, "Submit")
18
13
  """
19
14
 
20
15
  @staticmethod
21
- def find(wait: WebDriverWait, label: str):
16
+ def __findByLabelText(wait: WebDriverWait, label: str):
22
17
  """
23
- Finds a button element by its label.
18
+ Finds a button by its label.
24
19
 
25
20
  Parameters:
26
21
  wait: Selenium WebDriverWait instance.
27
- label: The visible text label of the button.
22
+ label: The label of the button to find.
23
+ label: The label of the button to find.
28
24
 
29
25
  Returns:
30
- The Selenium WebElement for the button.
26
+ WebElement representing the button.
31
27
 
32
28
  Example:
33
- ButtonUtils.find(wait, "Submit")
34
-
29
+ component = ButtonUtils.__findByLabelText(wait, "Submit")
35
30
  """
36
-
37
- # This method locates a button that contains a span with the specified label text.
38
-
39
31
  xpath = f".//button[./span[contains(translate(normalize-space(.), '\u00a0', ' '), '{label}')]]"
40
32
  try:
41
33
  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
34
  except Exception as e:
47
- raise RuntimeError(
48
- f"Button with label '{label}' not found or not clickable."
49
- ) from e
35
+ raise RuntimeError(f"Button with label '{label}' not found or not clickable.") from e
50
36
  return component
51
37
 
52
38
  @staticmethod
53
- def click(wait: WebDriverWait, label: str):
54
- """
55
- Clicks a button identified by its label.
39
+ def clickByLabelText(wait: WebDriverWait, label: str):
40
+ """Finds a button by its label and clicks it.
56
41
 
57
42
  Parameters:
58
43
  wait: Selenium WebDriverWait instance.
59
- label: The visible text label of the button.
60
- Example:
61
- ButtonUtils.click(wait, "Submit")
62
-
44
+ label: The label of the button to click.
45
+ Example:
46
+ ButtonUtils.clickByLabelText(wait, "Button Label")
63
47
  """
64
- component = ButtonUtils.find(wait, label)
48
+ component = ButtonUtils.__findByLabelText(wait, label)
65
49
  component.click()
66
50
 
67
51
  @staticmethod
68
- def clickInputButtonById(wait: WebDriverWait, id: str):
52
+ def clickById(wait: WebDriverWait, id: str):
69
53
  """
70
54
  Finds and clicks an input button by its HTML id attribute.
71
55
 
@@ -74,18 +58,12 @@ class ButtonUtils:
74
58
  id: The HTML id of the input button.
75
59
 
76
60
  Example:
77
- ButtonUtils.clickInputButtonById(wait, "button_id")
61
+ ButtonUtils.clickById(wait, "button_id")
78
62
 
79
63
  """
80
64
  try:
81
65
  component = wait.until(EC.element_to_be_clickable((By.ID, id)))
82
- except TimeoutError as e:
83
- raise TimeoutError(
84
- f"Input button with id '{id}' not found or not clickable."
85
- ) from e
86
66
  except Exception as e:
87
- raise RuntimeError(
88
- f"Input button with id '{id}' not found or not clickable."
89
- ) from e
67
+ raise RuntimeError(f"Input button with id '{id}' not found or not clickable.") from e
90
68
 
91
69
  component.click()
@@ -1,7 +1,6 @@
1
1
  from selenium.webdriver.common.by import By
2
2
  from selenium.webdriver.support import expected_conditions as EC
3
3
  from selenium.webdriver.support.ui import WebDriverWait
4
- from selenium.webdriver.remote.webelement import WebElement
5
4
 
6
5
  from robo_appian.components.InputUtils import InputUtils
7
6
 
@@ -9,137 +8,70 @@ from robo_appian.components.InputUtils import InputUtils
9
8
  class DateUtils:
10
9
  """
11
10
  Utility class for interacting with date components in Appian UI.
12
-
13
- Usage Example:
14
-
15
- # Set a date value
11
+ Usage Example:
12
+ # Set a date value in a date component
16
13
  from robo_appian.components.DateUtils import DateUtils
17
- DateUtils.setDateValue(wait, "Start Date", "01/01/2024")
18
-
14
+ DateUtils.setValueByLabelText(wait, "Start Date", "2023-10-01")
19
15
  """
20
16
 
21
17
  @staticmethod
22
- def findComponent(wait: WebDriverWait, label: str):
18
+ def __findComponent(wait: WebDriverWait, label: str):
23
19
  """
24
20
  Finds a date component by its label.
25
-
26
- Parameters:
27
- wait: Selenium WebDriverWait instance.
28
- label: The visible text label of the date component.
29
-
30
- Returns:
31
- The Selenium WebElement for the date component.
32
-
21
+ :param wait: WebDriverWait instance to wait for elements.
22
+ :param label: The label of the date component.
23
+ :return: The WebElement representing the date component.
33
24
  Example:
34
- DateUtils.findComponent(wait, "Start Date")
35
-
25
+ DateUtils.__findComponent(wait, "Start Date")
36
26
  """
37
-
38
- xpath = f".//div/label[text()='{label}']"
39
- try:
40
- component: WebElement = wait.until(
41
- EC.element_to_be_clickable((By.XPATH, xpath))
42
- )
43
- except TimeoutError as e:
44
- raise TimeoutError(
45
- f"Could not find clickable date component with label '{label}': {e}"
46
- )
47
- except Exception as e:
48
- raise Exception(
49
- f"Could not find clickable date component with label '{label}': {e}"
50
- )
51
-
52
- attribute: str = "for"
53
- component_id = component.get_attribute(attribute) # type: ignore[reportUnknownMemberType]
54
- if component_id is None:
55
- raise ValueError(
56
- f"Could not find component using {attribute} attribute for label '{label}'."
57
- )
58
-
27
+ # xpath = f".//div/label[text()='{label}']"
28
+ # try:
29
+ # component: WebElement = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
30
+ # except Exception as e:
31
+ # raise Exception(f"Could not find clickable date component with label '{label}': {e}")
32
+
33
+ # attribute: str = "for"
34
+ # component_id = component.get_attribute(attribute) # type: ignore[reportUnknownMemberType]
35
+ # if component_id is None:
36
+ # raise ValueError(f"Could not find component using {attribute} attribute for label '{label}'.")
37
+
38
+ # try:
39
+ # component = wait.until(EC.element_to_be_clickable((By.ID, component_id)))
40
+ # except Exception as e:
41
+ # raise Exception(f"Could not find clickable date input with id '{component_id}': {e}")
42
+
43
+ xpath = f'.//div[./div/label[text()="{label}"]]/div/div/div/input'
59
44
  try:
60
- component = wait.until(EC.element_to_be_clickable((By.ID, component_id)))
61
- except TimeoutError as e:
62
- raise TimeoutError(
63
- f"Could not find clickable date input with id '{component_id}': {e}"
64
- )
45
+ component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
65
46
  except Exception as e:
66
- raise Exception(
67
- f"Could not find clickable date input with id '{component_id}': {e}"
68
- )
47
+ raise Exception(f"Could not find clickable date component with label '{label}': {e}")
69
48
  return component
70
49
 
71
50
  @staticmethod
72
- def setDateValue(wait: WebDriverWait, label: str, value: str):
51
+ def setValueByLabelText(wait: WebDriverWait, label: str, value: str):
73
52
  """
74
- Sets a date value in a date component identified by its label.
75
-
76
- Parameters:
77
- wait: Selenium WebDriverWait instance.
78
- label: The visible text label of the date component.
79
- value: The date value to set (e.g., "01/01/2024").
80
-
81
- Returns:
82
- The Selenium WebElement for the date component after setting the value.
83
-
53
+ Sets the value of a date component.
54
+ :param wait: WebDriverWait instance to wait for elements.
55
+ :param label: The label of the date component.
56
+ :param value: The value to set in the date component.
57
+ :return: The WebElement representing the date component.
84
58
  Example:
85
- DateUtils.setDateValue(wait, "Start Date", "01/01/2024")
86
-
59
+ DateUtils.setValueByLabelText(wait, "Start Date", "2023-10-01")
87
60
  """
88
- # This method locates a date component that contains a label with the specified text.
89
- # It then retrieves the component's ID and uses it to find the actual input element.
90
- # component = wait.until(EC.element_to_be_clickable((By.XPATH, f".//div/label[text()='{label}']/following-sibling::input")))
91
-
92
- component = DateUtils.findComponent(wait, label)
93
- InputUtils._setComponentValue(component, value)
61
+ component = DateUtils.__findComponent(wait, label)
62
+ InputUtils._setValueByComponent(component, value)
94
63
  return component
95
64
 
96
65
  @staticmethod
97
- def setDateValueAndSubmit(wait: WebDriverWait, label: str, value: str):
66
+ def clickByLabelText(wait: WebDriverWait, label: str):
98
67
  """
99
- Sets a date value in a date component identified by its label and submits the form.
100
-
101
- Parameters:
102
- wait: Selenium WebDriverWait instance.
103
- label: The visible text label of the date component.
104
- value: The date value to set (e.g., "01/01/2024").
105
-
106
- Returns:
107
- The Selenium WebElement for the date component after setting the value.
108
-
68
+ Clicks on the date component to open the date picker.
69
+ :param wait: WebDriverWait instance to wait for elements.
70
+ :param label: The label of the date component.
71
+ :return: The WebElement representing the date component.
109
72
  Example:
110
- DateUtils.setDateValueAndSubmit(wait, "Start Date", "01/01/2024")
111
-
73
+ DateUtils.clickByLabelText(wait, "Start Date")
112
74
  """
113
-
114
- # This method locates a date component that contains a label with the specified text.
115
- # It then retrieves the component's ID and uses it to find the actual input element.
116
- # It sets the value of the input element and submits it.
117
-
118
- component = DateUtils.findComponent(wait, label)
119
- InputUtils.setValueAndSubmitByComponent(component, value)
120
-
121
- return component
122
-
123
- @staticmethod
124
- def click(wait: WebDriverWait, label: str):
125
- """
126
- Clicks on a date component identified by its label.
127
-
128
- Parameters:
129
- wait: Selenium WebDriverWait instance.
130
- label: The visible text label of the date component.
131
-
132
- Returns:
133
- The Selenium WebElement for the date component after clicking.
134
-
135
- Example:
136
- DateUtils.click(wait, "Start Date")
137
- """
138
- # This method locates a date component that contains a label with the specified text.
139
- # It then retrieves the component's ID and uses it to find the actual input element.
140
- # It clicks on the input element to open the date picker.
141
-
142
- component = DateUtils.findComponent(wait, label)
75
+ component = DateUtils.__findComponent(wait, label)
143
76
  component.click()
144
-
145
77
  return component