pomcorn 0.7.4__py3-none-any.whl → 0.8.0__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 pomcorn might be problematic. Click here for more details.
- pomcorn/component.py +33 -11
- pomcorn/element.py +0 -4
- {pomcorn-0.7.4.dist-info → pomcorn-0.8.0.dist-info}/METADATA +1 -1
- {pomcorn-0.7.4.dist-info → pomcorn-0.8.0.dist-info}/RECORD +6 -6
- {pomcorn-0.7.4.dist-info → pomcorn-0.8.0.dist-info}/WHEEL +1 -1
- {pomcorn-0.7.4.dist-info → pomcorn-0.8.0.dist-info}/LICENSE +0 -0
pomcorn/component.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Generic, TypeVar, overload
|
|
1
|
+
from typing import Generic, TypeVar, get_args, overload
|
|
2
2
|
|
|
3
3
|
from . import locators
|
|
4
4
|
from .element import XPathElement
|
|
@@ -177,21 +177,37 @@ class ListComponent(Generic[ListItemType, TPage], Component[TPage]):
|
|
|
177
177
|
* all
|
|
178
178
|
* get_item_by_text()
|
|
179
179
|
|
|
180
|
-
Waits for `base_item_locator` property to be implemented and value of
|
|
181
|
-
`item_class` to be set.
|
|
182
|
-
|
|
183
180
|
Waits for `base_item_locator` property to be overridden or one of the
|
|
184
181
|
attributes (`item_locator` or `relative_item_locator`) to be specified.
|
|
185
182
|
|
|
186
|
-
The `item_class` attribute is also required.
|
|
187
|
-
|
|
188
183
|
"""
|
|
189
184
|
|
|
190
|
-
item_class: type[ListItemType]
|
|
191
|
-
|
|
192
185
|
item_locator: locators.XPathLocator | None = None
|
|
193
186
|
relative_item_locator: locators.XPathLocator | None = None
|
|
194
187
|
|
|
188
|
+
def __init__(
|
|
189
|
+
self,
|
|
190
|
+
page: TPage,
|
|
191
|
+
base_locator: locators.XPathLocator | None = None,
|
|
192
|
+
wait_until_visible: bool = True,
|
|
193
|
+
):
|
|
194
|
+
super().__init__(page, base_locator, wait_until_visible)
|
|
195
|
+
if item_class := getattr(self, "item_class", None):
|
|
196
|
+
import warnings
|
|
197
|
+
|
|
198
|
+
warnings.warn(
|
|
199
|
+
DeprecationWarning(
|
|
200
|
+
"\nSpecifying `item_class` attribute in `ListComponent` "
|
|
201
|
+
f"({self.__class__}) is DEPRECATED. It is now "
|
|
202
|
+
"automatically substituted from Generic[ListItemType]. "
|
|
203
|
+
"Ability to specify this attribute will be removed soon.",
|
|
204
|
+
),
|
|
205
|
+
stacklevel=2,
|
|
206
|
+
)
|
|
207
|
+
self._item_class = item_class
|
|
208
|
+
else:
|
|
209
|
+
self._item_class = self._get_list_item_class()
|
|
210
|
+
|
|
195
211
|
@property
|
|
196
212
|
def base_item_locator(self) -> locators.XPathLocator:
|
|
197
213
|
"""Get the base locator of list item.
|
|
@@ -236,7 +252,9 @@ class ListComponent(Generic[ListItemType, TPage], Component[TPage]):
|
|
|
236
252
|
|
|
237
253
|
items: list[ListItemType] = []
|
|
238
254
|
for locator in self.iter_locators(self.base_item_locator):
|
|
239
|
-
items.append(
|
|
255
|
+
items.append(
|
|
256
|
+
self._item_class(page=self.page, base_locator=locator),
|
|
257
|
+
)
|
|
240
258
|
return items
|
|
241
259
|
|
|
242
260
|
def get_item_by_text(self, text: str) -> ListItemType:
|
|
@@ -244,13 +262,17 @@ class ListComponent(Generic[ListItemType, TPage], Component[TPage]):
|
|
|
244
262
|
locator = self.base_item_locator.extend_query(
|
|
245
263
|
extra_query=f"[contains(.,'{text}')]",
|
|
246
264
|
)
|
|
247
|
-
return self.
|
|
265
|
+
return self._item_class(page=self.page, base_locator=locator)
|
|
266
|
+
|
|
267
|
+
def _get_list_item_class(self) -> type[ListItemType]:
|
|
268
|
+
"""Return class passed in `Generic[ListItemType]`."""
|
|
269
|
+
return get_args(self.__orig_bases__[0])[0] # type: ignore
|
|
248
270
|
|
|
249
271
|
def __repr__(self) -> str:
|
|
250
272
|
return (
|
|
251
273
|
"ListComponent("
|
|
252
274
|
f"component={self.__class__}, "
|
|
253
|
-
f"item_class={self.
|
|
275
|
+
f"item_class={self._item_class}, "
|
|
254
276
|
f"base_item_locator={self.base_item_locator}, "
|
|
255
277
|
f"count={self.count}, "
|
|
256
278
|
f"items={self.all}, "
|
pomcorn/element.py
CHANGED
|
@@ -285,7 +285,6 @@ class PomcornElement(Generic[locators.TLocator]):
|
|
|
285
285
|
def click(
|
|
286
286
|
self,
|
|
287
287
|
only_visible: bool = True,
|
|
288
|
-
scroll_to: bool = True,
|
|
289
288
|
wait_until_clickable: bool = True,
|
|
290
289
|
):
|
|
291
290
|
"""Click on element.
|
|
@@ -293,13 +292,10 @@ class PomcornElement(Generic[locators.TLocator]):
|
|
|
293
292
|
Args:
|
|
294
293
|
only_visible: Flag for viewing visible elements. If this is `True`
|
|
295
294
|
(default), then this method will only get visible elements.
|
|
296
|
-
scroll_to: Whether to scroll to element before clicking or not.
|
|
297
295
|
wait_until_clickable: Wait until the element is clickable before
|
|
298
296
|
clicking, or not (default `True`).
|
|
299
297
|
|
|
300
298
|
"""
|
|
301
|
-
if scroll_to:
|
|
302
|
-
self.scroll_to(only_visible=only_visible)
|
|
303
299
|
if wait_until_clickable:
|
|
304
300
|
self.wait_until_clickable()
|
|
305
301
|
self.get_element(only_visible=only_visible).click()
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
pomcorn/__init__.py,sha256=V8v_V3wgKbao1KAQkcVTMnpGwyslw0nHfuTp-DwWTXg,318
|
|
2
|
-
pomcorn/component.py,sha256
|
|
2
|
+
pomcorn/component.py,sha256=-QoF5BnCKGqugUKHO4SPMKZJtmX6zLCVoZBQm9QzhIA,9286
|
|
3
3
|
pomcorn/descriptors/__init__.py,sha256=5q_d5GtcaFlIIyHdsUnE9UNbz3g40qJCHKNaWGvcC6s,72
|
|
4
4
|
pomcorn/descriptors/element.py,sha256=4g_4ay5f00AXzCT4xHN1i7mTrlsECoUHh1Ph_TFPBDs,4502
|
|
5
|
-
pomcorn/element.py,sha256=
|
|
5
|
+
pomcorn/element.py,sha256=6VLLSPlc7961qa4rRXdno7cEAAeY8GEP2d4wtM5R9a0,12216
|
|
6
6
|
pomcorn/exceptions.py,sha256=8ZOmrybDwvEVZRLQzyozjRNhJvSLbablaFwGFUVMhrU,1131
|
|
7
7
|
pomcorn/locators/__init__.py,sha256=hNSlfmz3y-LI4PXF5VIwX8J5WSalyE2wmzuYc6kNxMA,708
|
|
8
8
|
pomcorn/locators/base_locators.py,sha256=B4SDSKi5j7kqwbxllnMHU9BKBJzn_dzNRphPQ2hTuss,7065
|
|
@@ -11,7 +11,7 @@ pomcorn/page.py,sha256=wuLoGUn1n0e7wSXLGYyUVnoPlz_gMfT8Jtg6yA09IeY,5755
|
|
|
11
11
|
pomcorn/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
pomcorn/waits_conditions.py,sha256=E8sLfBvIV2EO91Mm5KyKXB5IGEB9gUWza3XPE4_aCQE,3528
|
|
13
13
|
pomcorn/web_view.py,sha256=PlwEVgdOwFZXJY2WuUT2C2wyK1xOBJne5-A_FOuwsQI,14209
|
|
14
|
-
pomcorn-0.
|
|
15
|
-
pomcorn-0.
|
|
16
|
-
pomcorn-0.
|
|
17
|
-
pomcorn-0.
|
|
14
|
+
pomcorn-0.8.0.dist-info/LICENSE,sha256=1vmhQNp1dDH8ksJ199LuG4oKz5D4ZvNccPcFckiG2S4,1091
|
|
15
|
+
pomcorn-0.8.0.dist-info/METADATA,sha256=YuVbebm1X8leLyFIAxmYbS4UqAUwT1iEaqmy70QhBkA,5949
|
|
16
|
+
pomcorn-0.8.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
17
|
+
pomcorn-0.8.0.dist-info/RECORD,,
|
|
File without changes
|