pomcorn 0.10.2__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.
pomcorn-0.10.2/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) 2023 Saritasa
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
20
+ OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: pomcorn
3
+ Version: 0.10.2
4
+ Summary: Base implementation of Page Object Model
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Keywords: python,selenium,webdriver,autotests,page object model,page object pattern,page object,pom,parsing,browser
8
+ Author: Saritasa
9
+ Author-email: pypi@saritasa.com
10
+ Maintainer: Anton Oboleninov
11
+ Maintainer-email: anton.oboleninov@saritasa.com
12
+ Requires-Python: >=3.11,<4.0
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Natural Language :: English
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Dist: selenium (>=4.12)
25
+ Project-URL: Documentation, http://pomcorn.rtfd.io/
26
+ Project-URL: Homepage, https://pypi.org/project/pomcorn/
27
+ Project-URL: Repository, https://github.com/saritasa-nest/pomcorn/
28
+ Description-Content-Type: text/markdown
29
+
30
+ # Pomcorn
31
+
32
+ ![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/saritasa-nest/pomcorn/pre-commit.yml) ![PyPI](https://img.shields.io/pypi/v/pomcorn) ![PyPI - Status](https://img.shields.io/pypi/status/pomcorn) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pomcorn) ![PyPI - License](https://img.shields.io/pypi/l/pomcorn) ![PyPI - Downloads](https://img.shields.io/pypi/dm/pomcorn) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
33
+
34
+
35
+ **Pomcorn**, or **Page Object Model corn**, is a Python package that contains base classes to create systems based on [Selenium](https://github.com/SeleniumHQ/selenium#selenium) framework and **Page Object Model** pattern. You can read more about this pattern [here](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/). The package can be used to create autotesting systems, parsing scripts and anything that requires
36
+ interaction with the browser.
37
+
38
+ The package includes next base classes to create Page Object Model (``POM``) pages:
39
+
40
+ ```mermaid
41
+ classDiagram
42
+ WebView <|-- Component
43
+ WebView <|-- Page
44
+ Component <|-- ListComponent
45
+ Component .. Locator
46
+ Page .. Component
47
+
48
+ class WebView{
49
+ -webdriver: Webdriver
50
+ }
51
+ class Page{
52
+ +wait_until_loaded()
53
+ +open()
54
+ }
55
+ class Component{
56
+ -page: Page
57
+ -base_locator: Locator
58
+ + wait_until_visible()
59
+ }
60
+ class ListComponent{
61
+ -item_locator: Locator
62
+ +count()
63
+ +all()
64
+ +get_item_by_text()
65
+ }
66
+ class Locator{
67
+ -query: String
68
+ }
69
+
70
+ ```
71
+
72
+ It also includes [classes to locate elements](https://pomcorn.readthedocs.io/en/latest/locators.html) on the web page and a number of additional [waiting conditions](https://pomcorn.readthedocs.io/en/latest/waits_conditions.html).
73
+
74
+ ## Installation
75
+
76
+ You can install it by **pip**:
77
+
78
+ ```bash
79
+ pip install pomcorn
80
+ ```
81
+
82
+ Or **poetry**:
83
+
84
+ ```bash
85
+ poetry add pomcorn
86
+ ```
87
+
88
+ ## Documentation
89
+
90
+ Link to the documentation: [http://pomcorn.rtfd.io/](http://pomcorn.rtfd.io/).
91
+
92
+ ## Usage
93
+
94
+ You need to [install pomcorn](https://pomcorn.readthedocs.io/en/latest/installation.html) and [Chrome webdriver](https://pomcorn.readthedocs.io/en/latest/installation.html#chrome-driver).
95
+
96
+ Below is the code that opens ``PyPI.org``, searches for packages by name and prints names of found packages to the terminal. The script contains all base classes contained in ``pomcorn``: **Page**, **Component**, **ListComponent** and **Element**.
97
+
98
+ ```python
99
+
100
+ from typing import Self
101
+
102
+ from selenium.webdriver import Chrome
103
+ from selenium.webdriver.common.keys import Keys
104
+ from selenium.webdriver.remote.webdriver import WebDriver
105
+
106
+ from pomcorn import Component, Element, ListComponent, Page, locators
107
+
108
+
109
+ # Prepare base page
110
+ class PyPIPage(Page):
111
+
112
+ APP_ROOT = "https://pypi.org"
113
+
114
+ search = Element(locators.IdLocator("search"))
115
+
116
+ def check_page_is_loaded(self) -> bool:
117
+ return self.init_element(locators.TagNameLocator("main")).is_displayed
118
+
119
+
120
+ # Prepare components
121
+ Package = Component[PyPIPage]
122
+
123
+
124
+ class PackageList(ListComponent[Package, PyPIPage]):
125
+
126
+ relative_item_locator = locators.ClassLocator("snippet__name")
127
+
128
+ @property
129
+ def names(self) -> list[str]:
130
+ return [package.body.get_text() for package in self.all]
131
+
132
+
133
+ # Prepare search page
134
+ class SearchPage(PyPIPage):
135
+
136
+ @classmethod
137
+ def open(cls, webdriver: WebDriver, **kwargs) -> Self:
138
+ pypi_page = super().open(webdriver, **kwargs)
139
+ # Specific logic for PyPI for an open search page
140
+ pypi_page.search.fill("")
141
+ pypi_page.search.send_keys(Keys.ENTER)
142
+ return cls(webdriver, **kwargs)
143
+
144
+ @property
145
+ def results(self) -> PackageList:
146
+ return PackageList(
147
+ page=self,
148
+ base_locator=locators.PropertyLocator(
149
+ prop="aria-label",
150
+ value="Search results",
151
+ ),
152
+ )
153
+
154
+ def find(self, query: str) -> PackageList:
155
+ self.search.fill(query)
156
+ self.search.send_keys(Keys.ENTER)
157
+ return self.results
158
+
159
+
160
+ search_page = SearchPage.open(webdriver=Chrome())
161
+ print(search_page.find("saritasa").names)
162
+ search_page.webdriver.close()
163
+ ```
164
+
165
+ For more information about package classes, you can read in [Object Hierarchy](https://pomcorn.readthedocs.io/en/latest/objects_hierarchy.html) and [Developer Interface](https://pomcorn.readthedocs.io/en/latest/developer_interface.html).
166
+
167
+ Also you can try our [demo autotests project](https://pomcorn.readthedocs.io/en/latest/demo.html).
168
+
@@ -0,0 +1,138 @@
1
+ # Pomcorn
2
+
3
+ ![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/saritasa-nest/pomcorn/pre-commit.yml) ![PyPI](https://img.shields.io/pypi/v/pomcorn) ![PyPI - Status](https://img.shields.io/pypi/status/pomcorn) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pomcorn) ![PyPI - License](https://img.shields.io/pypi/l/pomcorn) ![PyPI - Downloads](https://img.shields.io/pypi/dm/pomcorn) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
4
+
5
+
6
+ **Pomcorn**, or **Page Object Model corn**, is a Python package that contains base classes to create systems based on [Selenium](https://github.com/SeleniumHQ/selenium#selenium) framework and **Page Object Model** pattern. You can read more about this pattern [here](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/). The package can be used to create autotesting systems, parsing scripts and anything that requires
7
+ interaction with the browser.
8
+
9
+ The package includes next base classes to create Page Object Model (``POM``) pages:
10
+
11
+ ```mermaid
12
+ classDiagram
13
+ WebView <|-- Component
14
+ WebView <|-- Page
15
+ Component <|-- ListComponent
16
+ Component .. Locator
17
+ Page .. Component
18
+
19
+ class WebView{
20
+ -webdriver: Webdriver
21
+ }
22
+ class Page{
23
+ +wait_until_loaded()
24
+ +open()
25
+ }
26
+ class Component{
27
+ -page: Page
28
+ -base_locator: Locator
29
+ + wait_until_visible()
30
+ }
31
+ class ListComponent{
32
+ -item_locator: Locator
33
+ +count()
34
+ +all()
35
+ +get_item_by_text()
36
+ }
37
+ class Locator{
38
+ -query: String
39
+ }
40
+
41
+ ```
42
+
43
+ It also includes [classes to locate elements](https://pomcorn.readthedocs.io/en/latest/locators.html) on the web page and a number of additional [waiting conditions](https://pomcorn.readthedocs.io/en/latest/waits_conditions.html).
44
+
45
+ ## Installation
46
+
47
+ You can install it by **pip**:
48
+
49
+ ```bash
50
+ pip install pomcorn
51
+ ```
52
+
53
+ Or **poetry**:
54
+
55
+ ```bash
56
+ poetry add pomcorn
57
+ ```
58
+
59
+ ## Documentation
60
+
61
+ Link to the documentation: [http://pomcorn.rtfd.io/](http://pomcorn.rtfd.io/).
62
+
63
+ ## Usage
64
+
65
+ You need to [install pomcorn](https://pomcorn.readthedocs.io/en/latest/installation.html) and [Chrome webdriver](https://pomcorn.readthedocs.io/en/latest/installation.html#chrome-driver).
66
+
67
+ Below is the code that opens ``PyPI.org``, searches for packages by name and prints names of found packages to the terminal. The script contains all base classes contained in ``pomcorn``: **Page**, **Component**, **ListComponent** and **Element**.
68
+
69
+ ```python
70
+
71
+ from typing import Self
72
+
73
+ from selenium.webdriver import Chrome
74
+ from selenium.webdriver.common.keys import Keys
75
+ from selenium.webdriver.remote.webdriver import WebDriver
76
+
77
+ from pomcorn import Component, Element, ListComponent, Page, locators
78
+
79
+
80
+ # Prepare base page
81
+ class PyPIPage(Page):
82
+
83
+ APP_ROOT = "https://pypi.org"
84
+
85
+ search = Element(locators.IdLocator("search"))
86
+
87
+ def check_page_is_loaded(self) -> bool:
88
+ return self.init_element(locators.TagNameLocator("main")).is_displayed
89
+
90
+
91
+ # Prepare components
92
+ Package = Component[PyPIPage]
93
+
94
+
95
+ class PackageList(ListComponent[Package, PyPIPage]):
96
+
97
+ relative_item_locator = locators.ClassLocator("snippet__name")
98
+
99
+ @property
100
+ def names(self) -> list[str]:
101
+ return [package.body.get_text() for package in self.all]
102
+
103
+
104
+ # Prepare search page
105
+ class SearchPage(PyPIPage):
106
+
107
+ @classmethod
108
+ def open(cls, webdriver: WebDriver, **kwargs) -> Self:
109
+ pypi_page = super().open(webdriver, **kwargs)
110
+ # Specific logic for PyPI for an open search page
111
+ pypi_page.search.fill("")
112
+ pypi_page.search.send_keys(Keys.ENTER)
113
+ return cls(webdriver, **kwargs)
114
+
115
+ @property
116
+ def results(self) -> PackageList:
117
+ return PackageList(
118
+ page=self,
119
+ base_locator=locators.PropertyLocator(
120
+ prop="aria-label",
121
+ value="Search results",
122
+ ),
123
+ )
124
+
125
+ def find(self, query: str) -> PackageList:
126
+ self.search.fill(query)
127
+ self.search.send_keys(Keys.ENTER)
128
+ return self.results
129
+
130
+
131
+ search_page = SearchPage.open(webdriver=Chrome())
132
+ print(search_page.find("saritasa").names)
133
+ search_page.webdriver.close()
134
+ ```
135
+
136
+ For more information about package classes, you can read in [Object Hierarchy](https://pomcorn.readthedocs.io/en/latest/objects_hierarchy.html) and [Developer Interface](https://pomcorn.readthedocs.io/en/latest/developer_interface.html).
137
+
138
+ Also you can try our [demo autotests project](https://pomcorn.readthedocs.io/en/latest/demo.html).
@@ -0,0 +1,14 @@
1
+ from pomcorn.component import Component, ListComponent
2
+ from pomcorn.descriptors import Element
3
+ from pomcorn.element import XPathElement
4
+ from pomcorn.page import Page
5
+ from pomcorn.web_view import WebView
6
+
7
+ __all__ = (
8
+ "Component",
9
+ "Element",
10
+ "ListComponent",
11
+ "Page",
12
+ "WebView",
13
+ "XPathElement",
14
+ )