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

@@ -2,6 +2,7 @@ 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
4
  from selenium.webdriver.remote.webelement import WebElement
5
+ from robo_appian.utils.ComponentUtils import ComponentUtils
5
6
 
6
7
 
7
8
  class ButtonUtils:
@@ -36,32 +37,18 @@ class ButtonUtils:
36
37
  """
37
38
  xpath = f".//button[./span[contains(translate(normalize-space(.), '\u00a0', ' '), '{label}')]]"
38
39
  try:
39
- component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
40
+ component = ComponentUtils.findVisibleComponentByXpath(wait, xpath)
40
41
  except Exception as e:
41
42
  raise RuntimeError(f"Button with label '{label}' not found or not clickable.") from e
42
43
  return component
43
44
 
44
45
  @staticmethod
45
- def _findByLabelText(wait: WebDriverWait, label: str):
46
- """
47
- Finds a button by its label.
48
-
49
- Parameters:
50
- wait: Selenium WebDriverWait instance.
51
- label: The label of the button to find.
52
- label: The label of the button to find.
53
-
54
- Returns:
55
- WebElement representing the button.
56
-
57
- Example:
58
- component = ButtonUtils._findByLabelText(wait, "Submit")
59
- """
46
+ def __findByLabelText(wait: WebDriverWait, label: str):
60
47
  xpath = f".//button[./span[normalize-space(.)='{label}']]"
61
48
  try:
62
- component = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
49
+ component = ComponentUtils.findVisibleComponentByXpath(wait, xpath)
63
50
  except Exception as e:
64
- raise RuntimeError(f"Button with label '{label}' not found or not clickable.") from e
51
+ raise RuntimeError(f"Button with label '{label}' not found.") from e
65
52
  return component
66
53
 
67
54
  @staticmethod
@@ -87,7 +74,7 @@ class ButtonUtils:
87
74
  Example:
88
75
  ButtonUtils.clickByLabelText(wait, "Button Label")
89
76
  """
90
- component = ButtonUtils._findByLabelText(wait, label)
77
+ component = ButtonUtils.__findByLabelText(wait, label)
91
78
  ButtonUtils.__click(wait, component)
92
79
 
93
80
  @staticmethod
@@ -109,3 +96,19 @@ class ButtonUtils:
109
96
  raise RuntimeError(f"Input button with id '{id}' not found or not clickable.") from e
110
97
 
111
98
  ButtonUtils.__click(wait, component)
99
+
100
+ @staticmethod
101
+ def checkButtonExistsByLabelText(wait: WebDriverWait, label: str):
102
+ try:
103
+ ButtonUtils.__findByLabelText(wait, label)
104
+ except Exception:
105
+ return False
106
+ return True
107
+
108
+ @staticmethod
109
+ def checkButtonExistsByPartialLabelText(wait: WebDriverWait, label: str):
110
+ try:
111
+ ButtonUtils.__findByLabelText(wait, label)
112
+ except Exception:
113
+ return False
114
+ return True
@@ -1,5 +1,4 @@
1
1
  from robo_appian.utils.ComponentUtils import ComponentUtils
2
- from selenium.webdriver.common.by import By
3
2
  from selenium.webdriver.support import expected_conditions as EC
4
3
  from selenium.webdriver.support.ui import WebDriverWait
5
4
  from selenium.webdriver.remote.webelement import WebElement
@@ -19,70 +18,53 @@ class InputUtils:
19
18
  """
20
19
 
21
20
  @staticmethod
22
- def __findInputComponentsByXpath(wait: WebDriverWait, xpath: str):
21
+ def __findComponentByPartialLabel(wait: WebDriverWait, label: str):
23
22
  """
24
- Finds input components by their XPath.
23
+ Finds an input component by its label text, allowing for partial matches.
25
24
 
26
25
  Parameters:
27
26
  wait: Selenium WebDriverWait instance.
28
- xpath: The XPath expression to locate the input components.
27
+ label: The visible text label of the input component, allowing for partial matches.
29
28
 
30
29
  Returns:
31
- A list of Selenium WebElement representing the input components.
30
+ A Selenium WebElement representing the input component.
32
31
 
33
32
  Example:
34
- InputUtils.__findInputComponentsByXpath(wait, './/div/label[normalize-space(.)="Username"]')
33
+ InputUtils.__findInputComponentByPartialLabel(wait, "User")
35
34
  """
36
- label_components = ComponentUtils.findComponentsByXPath(wait, xpath)
37
- input_components = []
38
- for label_component in label_components:
39
- attribute: str = "for"
40
- component_id = label_component.get_attribute(attribute) # type: ignore[reportUnknownMemberType]
41
- if component_id:
42
- try:
43
- component = wait.until(EC.element_to_be_clickable((By.ID, component_id)))
44
- input_components.append(component)
45
- except Exception as e:
46
- raise Exception(f"Could not find clickable input component with id '{component_id}': {e}")
47
- else:
48
- raise ValueError(f"Input component with label '{label_component.text}' does not have 'for' attribute.")
49
- return input_components
50
-
51
- @staticmethod
52
- def __findInputComponentsByPartialLabel(wait: WebDriverWait, label: str):
53
- """Finds input components by their label text, allowing for partial matches.
54
35
 
55
- Parameters:
56
- wait: Selenium WebDriverWait instance.
57
- label: The visible text label of the input component, allowing for partial matches.
36
+ xpath = f'.//div/label[contains(normalize-space(.), "{label}")]'
37
+ label_component = ComponentUtils.findVisibleComponentByXpath(wait, xpath)
58
38
 
59
- Returns:
60
- A list of Selenium WebElement representing the input components.
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.")
61
42
 
62
- Example:
63
- InputUtils.__findInputComponentsByPartialLabel(wait, "Username")
64
- """
65
- xpath = f'.//div/label[contains(normalize-space(.), "{label}")]'
66
- components = InputUtils.__findInputComponentsByXpath(wait, xpath)
67
- return components
43
+ component = ComponentUtils.findComponentById(wait, input_id)
44
+ return component
68
45
 
69
46
  @staticmethod
70
- def __findComponentsByLabel(wait: WebDriverWait, label: str):
71
- """Finds input components by their label text.
72
-
47
+ def __findComponentByLabel(wait: WebDriverWait, label: str):
48
+ """Finds a component by its label text.
73
49
  Parameters:
74
50
  wait: Selenium WebDriverWait instance.
75
51
  label: The visible text label of the input component.
76
52
 
77
53
  Returns:
78
- A list of Selenium WebElement representing the input components.
54
+ A Selenium WebElement representing the input component.
79
55
 
80
56
  Example:
81
- InputUtils.__findComponentsByLabel(wait, "Username")
57
+ InputUtils.__findComponentByLabel(wait, "Username")
82
58
  """
59
+
83
60
  xpath = f'.//div/label[normalize-space(.)="{label}"]'
84
- components = InputUtils.__findInputComponentsByXpath(wait, xpath)
85
- return components
61
+ label_component = ComponentUtils.findVisibleComponentByXpath(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
86
68
 
87
69
  @staticmethod
88
70
  def _setValueByComponent(wait: WebDriverWait, component: WebElement, value: str):
@@ -102,26 +84,20 @@ class InputUtils:
102
84
  return component
103
85
 
104
86
  @staticmethod
105
- def __setValueByComponents(wait: WebDriverWait, input_components, value: str):
87
+ def setValueByPartialLabelText(wait: WebDriverWait, label: str, value: str):
106
88
  """
107
- Sets a value in an input component identified by its label text.
89
+ Sets a value in an input component identified by its partial label text.
90
+
108
91
  Parameters:
109
92
  wait: Selenium WebDriverWait instance.
110
- label: The visible text label of the input component.
93
+ label: The visible text label of the input component (partial match).
111
94
  value: The value to set in the input field.
95
+
112
96
  Returns:
113
97
  None
114
- Example:
115
- InputUtils.setValueByLabelText(wait, "Username", "test_user")
116
98
  """
117
-
118
- for component in input_components:
119
- InputUtils._setValueByComponent(wait, component, value)
120
-
121
- @staticmethod
122
- def setValueByPartialLabelText(wait: WebDriverWait, label: str, value: str):
123
- input_components = InputUtils.__findInputComponentsByPartialLabel(wait, label)
124
- InputUtils.__setValueByComponents(wait, input_components, value)
99
+ component = InputUtils.__findComponentByPartialLabel(wait, label)
100
+ InputUtils._setValueByComponent(wait, component, value)
125
101
 
126
102
  @staticmethod
127
103
  def setValueByLabelText(wait: WebDriverWait, label: str, value: str):
@@ -139,17 +115,17 @@ class InputUtils:
139
115
  Example:
140
116
  InputUtils.setValueByLabelText(wait, "Username", "test_user")
141
117
  """
142
- input_components = InputUtils.__findComponentsByLabel(wait, label)
143
- InputUtils.__setValueByComponents(wait, input_components, value)
118
+ component = InputUtils.__findComponentByLabel(wait, label)
119
+ InputUtils._setValueByComponent(wait, component, value)
144
120
 
145
121
  @staticmethod
146
- def setValueById(wait: WebDriverWait, component_id: str, value: str):
122
+ def setValueById(wait: WebDriverWait, id: str, value: str):
147
123
  """
148
124
  Sets a value in an input component identified by its ID.
149
125
 
150
126
  Parameters:
151
127
  wait: Selenium WebDriverWait instance.
152
- component_id: The ID of the input component.
128
+ id: The ID of the input component.
153
129
  value: The value to set in the input field.
154
130
 
155
131
  Returns:
@@ -158,9 +134,28 @@ class InputUtils:
158
134
  Example:
159
135
  InputUtils.setValueById(wait, "inputComponentId", "test_value")
160
136
  """
161
- try:
162
- component = wait.until(EC.element_to_be_clickable((By.ID, component_id)))
163
- except Exception as e:
164
- raise Exception(f"Timeout or error finding input component with id '{component_id}': {e}")
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.findVisibleComponentByXpath(wait, xpath)
165
161
  InputUtils._setValueByComponent(wait, component, value)
166
- return component
@@ -1,6 +1,6 @@
1
- from selenium.webdriver.common.by import By
2
1
  from selenium.webdriver.support import expected_conditions as EC
3
2
  from selenium.webdriver.support.ui import WebDriverWait
3
+ from robo_appian.utils.ComponentUtils import ComponentUtils
4
4
 
5
5
 
6
6
  class LabelUtils:
@@ -26,7 +26,8 @@ class LabelUtils:
26
26
  """
27
27
  xpath = f".//*[normalize-space(.)='{label}']"
28
28
  try:
29
- component = wait.until(EC.visibility_of_element_located((By.XPATH, xpath)))
29
+ # component = wait.until(EC.visibility_of_element_located((By.XPATH, xpath)))
30
+ component = ComponentUtils.findVisibleComponentByXpath(wait, xpath)
30
31
  except Exception as e:
31
32
  raise RuntimeError(f"Label with text '{label}' not found.") from e
32
33
 
@@ -1,5 +1,7 @@
1
1
  from selenium.webdriver.common.by import By
2
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
3
5
  from robo_appian.utils.ComponentUtils import ComponentUtils
4
6
 
5
7
 
@@ -22,9 +24,16 @@ class TabUtils:
22
24
 
23
25
  driver.quit()
24
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.")
25
34
 
26
35
  @staticmethod
27
- def findTabByLabelText(wait, label):
36
+ def findTabByLabelText(wait: WebDriverWait, label: str) -> WebElement:
28
37
  xpath = f'//div/div[@role="link" ]/div/div/div/div/div/p[normalize-space(.)="{label}"]'
29
38
  try:
30
39
  component = wait.until(EC.visibility_of_element_located((By.XPATH, xpath)))
@@ -33,16 +42,12 @@ class TabUtils:
33
42
  return component
34
43
 
35
44
  @staticmethod
36
- def selectTabByLabelText(wait, label):
45
+ def selectTabByLabelText(wait: WebDriverWait, label: str):
37
46
  component = TabUtils.findTabByLabelText(wait, label)
38
- try:
39
- component = wait.until(EC.element_to_be_clickable(component))
40
- except Exception:
41
- raise Exception(f"Tab with label '{label}' is not clickable.")
42
- component.click()
47
+ TabUtils.__click(wait, component, label)
43
48
 
44
49
  @staticmethod
45
- def checkTabSelectedByLabelText(wait, label):
50
+ def checkTabSelectedByLabelText(wait: WebDriverWait, label: str):
46
51
  component = TabUtils.findTabByLabelText(wait, label)
47
52
 
48
53
  select_text = "Selected Tab."
@@ -73,21 +73,31 @@ class ComponentUtils:
73
73
  xpath = "//button[@id='submit']"
74
74
  ComponentUtils.findComponentUsingXpathAndClick(wait, xpath)
75
75
  """
76
- component = ComponentUtils.findComponentUsingXpath(wait, xpath)
76
+ component = ComponentUtils.findVisibleComponentByXpath(wait, xpath)
77
77
  component.click()
78
78
 
79
79
  @staticmethod
80
- def findComponentUsingXpath(wait: WebDriverWait, xpath: str):
81
- """Finds a component using the given XPath in the current WebDriver instance.
80
+ def findComponentById(wait: WebDriverWait, id: str):
81
+ try:
82
+ component = wait.until(EC.presence_of_element_located((By.ID, id)))
83
+ except Exception:
84
+ raise Exception(f"Component with ID '{id}' not found.")
85
+ return component
86
+
87
+ @staticmethod
88
+ def findVisibleComponentByXpath(wait: WebDriverWait, xpath: str):
89
+ """
90
+ Finds a component using the given XPath in the current WebDriver instance.
91
+
92
+ :param wait: WebDriverWait instance to wait for elements
93
+ :param xpath: XPath string to locate the component
94
+ :return: WebElement if found, raises NoSuchElementException otherwise
82
95
 
83
- :param wait: WebDriverWait instance to wait for elements
84
- :param xpath: XPath string to locate the component
85
- :return: WebElement if found, raises NoSuchElementException otherwise
86
96
  Example usage:
87
- component = ComponentUtils.findComponentUsingXpath(wait, "//button[@id='submit']")
88
- component.click()
97
+ component = ComponentUtils.findVisibleComponentByXpath(wait, "//button[@id='submit']")
98
+ component.click()
89
99
  """
90
- component = wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
100
+ component = wait.until(EC.visibility_of_element_located((By.XPATH, xpath)))
91
101
  return component
92
102
 
93
103
  @staticmethod
@@ -95,7 +105,7 @@ class ComponentUtils:
95
105
  """Checks if a component with the given XPath exists in the current WebDriver instance."""
96
106
  status = False
97
107
  try:
98
- ComponentUtils.findComponentUsingXpath(wait, xpath)
108
+ ComponentUtils.findVisibleComponentByXpath(wait, xpath)
99
109
  status = True
100
110
  except NoSuchElementException:
101
111
  pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: robo_appian
3
- Version: 0.0.17
3
+ Version: 0.0.19
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,22 +1,22 @@
1
1
  robo_appian/__init__.py,sha256=6u9n2W7P1IKSSr5IPGsg7LhVR1o1uYv424mXDjJLgb0,720
2
- robo_appian/components/ButtonUtils.py,sha256=qFe84Pv3J64X2oqBvbOEnyZPudcCOK_Rrz-PAEAahM4,3874
2
+ robo_appian/components/ButtonUtils.py,sha256=4zF7lDvn1DMIX3nI7Nl9glC1NYfFpvVj43a8N215Bx4,3990
3
3
  robo_appian/components/DateUtils.py,sha256=3iptq3IDCy4IwefEyPtvEQ1nUFI1OVpTF3dAnViHIoM,3258
4
4
  robo_appian/components/DropdownUtils.py,sha256=X_ucR4uCiU3fnsMXGnJC9PTfwbfW3w3ulzyuURh1Vlw,11149
5
- robo_appian/components/InputUtils.py,sha256=LNPNX2TYubPS7sgOx329JPixTrbtZZ7XhhpUolC9XYw,6514
6
- robo_appian/components/LabelUtils.py,sha256=Fue3BDpqvHKGK_vBOtMld3Lai3ZQ2wzZPeQJESrjUF8,1860
5
+ robo_appian/components/InputUtils.py,sha256=78O7G8mNjEBVdrZUjlL9PMvDzTZ9uHEm0rDB5MsuYRQ,6050
6
+ robo_appian/components/LabelUtils.py,sha256=d0IUm330RokFRny3CdRGNOzGtDHYqZT0WzVS1TgSscI,1958
7
7
  robo_appian/components/LinkUtils.py,sha256=_m9dpHW9mUJFMcLp95K2s-YDYAvG-RlPF6giw3dmYcE,1389
8
8
  robo_appian/components/SearchDropdownUtils.py,sha256=rjsC3kd8Z-eHAAzF4OBJVchStRV5pCB2dtpVEL6cdCQ,4519
9
9
  robo_appian/components/SearchInputUtils.py,sha256=7sI8D6MXDzBPwbkIQodtxvXD2aA-8HiqvDCEJUlekZo,3263
10
- robo_appian/components/TabUtils.py,sha256=uW90mZxO1OaU79NKarC62dVyBsKPjbCkjyh004TH2fo,1923
10
+ robo_appian/components/TabUtils.py,sha256=k-HkIK8ca-KnHXSDTXDV4190jT5P84tZ3frWSCndn5I,2257
11
11
  robo_appian/components/TableUtils.py,sha256=SmtB4jq0XGZc0smMTe1HRvcCurQTXz3CytswbogfwTY,6059
12
12
  robo_appian/components/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  robo_appian/controllers/ComponentDriver.py,sha256=jNaQrbKCFFyahpLKmipsA0v3p3bpjy9dMgW36IdE-Fw,4353
14
14
  robo_appian/controllers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  robo_appian/exceptions/MyCustomError.py,sha256=DVAkytXNNQNjqyTyCjk6FFd6fr3AsBe57Y19erDSqVs,222
16
16
  robo_appian/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- robo_appian/utils/ComponentUtils.py,sha256=sHHT-mcdhZs9hHIAVD3KkrgLFXn4gIo58NsHHhI156w,7088
17
+ robo_appian/utils/ComponentUtils.py,sha256=AR9Z_RYH939KZv4yX2cpilIaZ83-DVXWCYUcuke81iE,7424
18
18
  robo_appian/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- robo_appian-0.0.17.dist-info/LICENSE,sha256=g-xR4dRa9_4iFkMoJmED-wE-J5hoxbk3105Knhfpjm0,1068
20
- robo_appian-0.0.17.dist-info/METADATA,sha256=JBsZBNYNEG84cOfOJXYNbQYmu-VVK0PeXVld9QnajOw,2261
21
- robo_appian-0.0.17.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
22
- robo_appian-0.0.17.dist-info/RECORD,,
19
+ robo_appian-0.0.19.dist-info/LICENSE,sha256=g-xR4dRa9_4iFkMoJmED-wE-J5hoxbk3105Knhfpjm0,1068
20
+ robo_appian-0.0.19.dist-info/METADATA,sha256=RW32QbdJS10nDZOjv74t8j_E0VeQe-Cn7pHjjUxSXSU,2261
21
+ robo_appian-0.0.19.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
22
+ robo_appian-0.0.19.dist-info/RECORD,,