pomcorn 0.4.0__tar.gz → 0.5.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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pomcorn
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: Base implementation of Page Object Model
5
5
  Home-page: https://pypi.org/project/pomcorn/
6
6
  License: MIT
@@ -1,4 +1,3 @@
1
- import abc
2
1
  from typing import Generic, TypeVar, overload
3
2
 
4
3
  from . import locators
@@ -34,10 +33,12 @@ 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.
@@ -46,14 +47,14 @@ class ComponentWithBaseLocator(Generic[TPage], Component[TPage]):
46
47
  page: An instance of the page that uses this component.
47
48
  base_locator: 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
- @abc.abstractproperty
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
- raise NotImplementedError
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:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pomcorn"
3
- version = "0.4.0"
3
+ version = "0.5.0"
4
4
  description = "Base implementation of Page Object Model"
5
5
  authors = [
6
6
  "Saritasa <pypi@saritasa.com>",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes