pomcorn 0.4.0__tar.gz → 0.6.0__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 pomcorn might be problematic. Click here for more details.
- {pomcorn-0.4.0 → pomcorn-0.6.0}/PKG-INFO +1 -1
- {pomcorn-0.4.0 → pomcorn-0.6.0}/pomcorn/component.py +41 -10
- {pomcorn-0.4.0 → pomcorn-0.6.0}/pomcorn/locators/xpath_locators.py +28 -1
- {pomcorn-0.4.0 → pomcorn-0.6.0}/pomcorn/page.py +8 -4
- {pomcorn-0.4.0 → pomcorn-0.6.0}/pyproject.toml +1 -1
- {pomcorn-0.4.0 → pomcorn-0.6.0}/LICENSE +0 -0
- {pomcorn-0.4.0 → pomcorn-0.6.0}/README.rst +0 -0
- {pomcorn-0.4.0 → pomcorn-0.6.0}/pomcorn/__init__.py +0 -0
- {pomcorn-0.4.0 → pomcorn-0.6.0}/pomcorn/element.py +0 -0
- {pomcorn-0.4.0 → pomcorn-0.6.0}/pomcorn/exceptions.py +0 -0
- {pomcorn-0.4.0 → pomcorn-0.6.0}/pomcorn/locators/__init__.py +0 -0
- {pomcorn-0.4.0 → pomcorn-0.6.0}/pomcorn/locators/base_locators.py +0 -0
- {pomcorn-0.4.0 → pomcorn-0.6.0}/pomcorn/py.typed +0 -0
- {pomcorn-0.4.0 → pomcorn-0.6.0}/pomcorn/waits_conditions.py +0 -0
- {pomcorn-0.4.0 → pomcorn-0.6.0}/pomcorn/web_view.py +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import abc
|
|
2
1
|
from typing import Generic, TypeVar, overload
|
|
3
2
|
|
|
4
3
|
from . import locators
|
|
@@ -34,26 +33,28 @@ class ComponentWithBaseLocator(Generic[TPage], Component[TPage]):
|
|
|
34
33
|
|
|
35
34
|
"""
|
|
36
35
|
|
|
36
|
+
base_locator: locators.XPathLocator
|
|
37
|
+
|
|
37
38
|
def __init__(
|
|
38
39
|
self,
|
|
39
40
|
page: TPage,
|
|
40
|
-
base_locator: locators.XPathLocator,
|
|
41
|
+
base_locator: locators.XPathLocator | None = None,
|
|
41
42
|
wait_until_visible: bool = True,
|
|
42
43
|
):
|
|
43
44
|
"""Initialize component.
|
|
44
45
|
|
|
45
46
|
Args:
|
|
46
47
|
page: An instance of the page that uses this component.
|
|
47
|
-
base_locator:
|
|
48
|
+
base_locator: Instance of a class to locate the element in
|
|
48
49
|
the browser. Used in relative element initialization methods
|
|
49
|
-
and visibility waits.
|
|
50
|
+
and visibility waits. You also can specify it as attribute.
|
|
50
51
|
wait_until_visible: Whether to wait for the component to become
|
|
51
52
|
visible before completing initialization or not.
|
|
52
53
|
|
|
53
54
|
"""
|
|
54
55
|
super().__init__(page)
|
|
55
|
-
self.base_locator = base_locator
|
|
56
|
-
self.body = self.init_element(locator=base_locator)
|
|
56
|
+
self.base_locator = base_locator or self.base_locator
|
|
57
|
+
self.body = self.init_element(locator=self.base_locator)
|
|
57
58
|
|
|
58
59
|
if wait_until_visible:
|
|
59
60
|
self.wait_until_visible()
|
|
@@ -194,14 +195,44 @@ class ListComponent(
|
|
|
194
195
|
Waits for `base_item_locator` property to be implemented and value of
|
|
195
196
|
`item_class` to be set.
|
|
196
197
|
|
|
198
|
+
Waits for `base_item_locator` property to be overridden or one of the
|
|
199
|
+
attributes (`item_locator` or `relative_item_locator`) to be specified.
|
|
200
|
+
|
|
201
|
+
The `item_class` attribute is also required.
|
|
202
|
+
|
|
197
203
|
"""
|
|
198
204
|
|
|
199
205
|
item_class: type[ListItemType]
|
|
200
206
|
|
|
201
|
-
|
|
207
|
+
item_locator: locators.XPathLocator | None = None
|
|
208
|
+
relative_item_locator: locators.XPathLocator | None = None
|
|
209
|
+
|
|
210
|
+
@property
|
|
202
211
|
def base_item_locator(self) -> locators.XPathLocator:
|
|
203
|
-
"""Get the base locator of list item.
|
|
204
|
-
|
|
212
|
+
"""Get the base locator of list item.
|
|
213
|
+
|
|
214
|
+
Raises:
|
|
215
|
+
ValueError: If both attributes are specified.
|
|
216
|
+
NotImplementedError: If no attribute has been specified,
|
|
217
|
+
|
|
218
|
+
"""
|
|
219
|
+
if self.relative_item_locator and self.item_locator:
|
|
220
|
+
raise ValueError(
|
|
221
|
+
"You only need to specify one of the attributes: "
|
|
222
|
+
"`relative_item_locator` - if you want locator nested within "
|
|
223
|
+
"`base_locator`, `item_locator` - otherwise. "
|
|
224
|
+
"Or override `base_item_locator` property.",
|
|
225
|
+
)
|
|
226
|
+
if not self.relative_item_locator:
|
|
227
|
+
if not self.item_locator:
|
|
228
|
+
raise NotImplementedError(
|
|
229
|
+
"You need to specify one of the arguments: "
|
|
230
|
+
"`relative_item_locator` - if you want locator nested "
|
|
231
|
+
"within `base_locator`, `item_locator` - otherwise. "
|
|
232
|
+
"Or override `base_item_locator` property.",
|
|
233
|
+
)
|
|
234
|
+
return self.item_locator
|
|
235
|
+
return self.base_locator // self.relative_item_locator
|
|
205
236
|
|
|
206
237
|
@property
|
|
207
238
|
def count(self) -> int:
|
|
@@ -220,7 +251,7 @@ class ListComponent(
|
|
|
220
251
|
|
|
221
252
|
items: list[ListItemType] = []
|
|
222
253
|
for locator in self.iter_locators(self.base_item_locator):
|
|
223
|
-
items.append(self.item_class(self.page, locator))
|
|
254
|
+
items.append(self.item_class(page=self.page, base_locator=locator))
|
|
224
255
|
return items
|
|
225
256
|
|
|
226
257
|
def get_item_by_text(self, text: str) -> ListItemType:
|
|
@@ -200,13 +200,18 @@ class ButtonWithTextLocator(ElementWithTextLocator):
|
|
|
200
200
|
super().__init__(text=text, element="button", exact=exact)
|
|
201
201
|
|
|
202
202
|
|
|
203
|
-
class
|
|
203
|
+
class InputInLabelLocator(XPathLocator):
|
|
204
204
|
"""Locator to looking for input with label by XPath.
|
|
205
205
|
|
|
206
206
|
Specify the query as the string
|
|
207
207
|
``//label[contains(., "label")]//input``, where ``label`` is the text of
|
|
208
208
|
the input label.
|
|
209
209
|
|
|
210
|
+
Example:
|
|
211
|
+
<label>Title</label>
|
|
212
|
+
<input value="Value">
|
|
213
|
+
</label>
|
|
214
|
+
|
|
210
215
|
"""
|
|
211
216
|
|
|
212
217
|
def __init__(self, label: str):
|
|
@@ -216,6 +221,28 @@ class InputByLabelLocator(XPathLocator):
|
|
|
216
221
|
)
|
|
217
222
|
|
|
218
223
|
|
|
224
|
+
class InputByLabelLocator(XPathLocator):
|
|
225
|
+
"""Locator to looking for input next to label by XPath.
|
|
226
|
+
|
|
227
|
+
Specify the query as the string
|
|
228
|
+
``//label[contains(., "label")]/following-sibling::input``, where ``label``
|
|
229
|
+
is the text of the input label.
|
|
230
|
+
|
|
231
|
+
Example:
|
|
232
|
+
<div>
|
|
233
|
+
<label for="InputWithLabel">Title</label>
|
|
234
|
+
<input id="InputWithLabel" value="Value">
|
|
235
|
+
</div>
|
|
236
|
+
|
|
237
|
+
"""
|
|
238
|
+
|
|
239
|
+
def __init__(self, label: str):
|
|
240
|
+
"""Init XPathLocator."""
|
|
241
|
+
super().__init__(
|
|
242
|
+
query=f'//label[contains(., "{label}")]/following-sibling::input',
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
|
|
219
246
|
class TextAreaByLabelLocator(XPathLocator):
|
|
220
247
|
"""Locator to looking for textarea with label by XPath.
|
|
221
248
|
|
|
@@ -3,7 +3,6 @@ from typing import Self
|
|
|
3
3
|
from selenium.common.exceptions import TimeoutException
|
|
4
4
|
from selenium.webdriver.remote.webdriver import WebDriver
|
|
5
5
|
|
|
6
|
-
from . import locators
|
|
7
6
|
from .exceptions import PageDidNotLoadedError
|
|
8
7
|
from .web_view import WebView
|
|
9
8
|
|
|
@@ -146,14 +145,19 @@ class Page(WebView):
|
|
|
146
145
|
self._get_full_relative_url(self.app_root, relative_url),
|
|
147
146
|
)
|
|
148
147
|
|
|
149
|
-
def click_on_page(self):
|
|
150
|
-
"""Click on
|
|
148
|
+
def click_on_page(self) -> None:
|
|
149
|
+
"""Click on (1, 1) coordinates in the upper left corner of the page.
|
|
151
150
|
|
|
152
151
|
Allows you to move focus away from an element, for example, if it
|
|
153
152
|
is currently unavailable for interaction.
|
|
154
153
|
|
|
155
154
|
"""
|
|
156
|
-
|
|
155
|
+
from selenium.webdriver.common.action_chains import ActionChains
|
|
156
|
+
|
|
157
|
+
ActionChains(self.webdriver).move_by_offset(
|
|
158
|
+
xoffset=1, # cspell:disable-line
|
|
159
|
+
yoffset=1, # cspell:disable-line
|
|
160
|
+
).click().perform()
|
|
157
161
|
|
|
158
162
|
@staticmethod
|
|
159
163
|
def _get_full_relative_url(app_root: str, relative_url: str) -> str:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|