pomcorn 0.8.7__py3-none-any.whl → 0.9.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/locators/base_locators.py +23 -7
- {pomcorn-0.8.7.dist-info → pomcorn-0.9.0.dist-info}/METADATA +1 -1
- {pomcorn-0.8.7.dist-info → pomcorn-0.9.0.dist-info}/RECORD +5 -5
- {pomcorn-0.8.7.dist-info → pomcorn-0.9.0.dist-info}/LICENSE +0 -0
- {pomcorn-0.8.7.dist-info → pomcorn-0.9.0.dist-info}/WHEEL +0 -0
|
@@ -157,25 +157,41 @@ class XPathLocator(Locator):
|
|
|
157
157
|
"""
|
|
158
158
|
return XPathLocator(query=f"({self.query} | {other.query})")
|
|
159
159
|
|
|
160
|
-
def __getitem__(self,
|
|
161
|
-
"""Allow
|
|
160
|
+
def __getitem__(self, value: int | str | XPathLocator) -> XPathLocator:
|
|
161
|
+
"""Allow to set xpath expressions or index into the locator query.
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
Examples:
|
|
164
164
|
div_locator = XPathLocator("//div") --> `//div`
|
|
165
|
+
|
|
166
|
+
# Indexation
|
|
165
167
|
div_locator[0] --> `(//div)[1]` # xpath numeration starts with 1
|
|
166
168
|
div_locator[-1] --> `(//div)[last()]`
|
|
167
169
|
|
|
170
|
+
# Attribute condition
|
|
171
|
+
div_locator["@type='black'"] --> `//div[@type='black']
|
|
172
|
+
|
|
173
|
+
# Checking if there are children
|
|
174
|
+
child_locator = XPathLocator("//label").contains("Schedule")
|
|
175
|
+
--> `//label[contains(., 'Star']`
|
|
176
|
+
div_locator[child_locator] --> `//div[//label[contains(., 'Star']]`
|
|
177
|
+
|
|
168
178
|
"""
|
|
169
179
|
query = f"({self.query})"
|
|
170
180
|
|
|
171
|
-
if
|
|
181
|
+
if isinstance(value, XPathLocator):
|
|
182
|
+
value = value.query
|
|
183
|
+
|
|
184
|
+
if isinstance(value, str):
|
|
185
|
+
return XPathLocator(f"{query}[{value}]")
|
|
186
|
+
|
|
187
|
+
if value >= 0:
|
|
172
188
|
# `+1` is used here because numeration in xpath starts with 1
|
|
173
|
-
query += f"[{
|
|
174
|
-
elif
|
|
189
|
+
query += f"[{value + 1}]"
|
|
190
|
+
elif value == -1:
|
|
175
191
|
# To avoid ugly locators with `...)[last() - 0]`
|
|
176
192
|
query += "[last()]"
|
|
177
193
|
else:
|
|
178
|
-
query += f"[last() - {abs(
|
|
194
|
+
query += f"[last() - {abs(value + 1)}]"
|
|
179
195
|
|
|
180
196
|
return XPathLocator(query)
|
|
181
197
|
|
|
@@ -4,13 +4,13 @@ pomcorn/descriptors/__init__.py,sha256=5q_d5GtcaFlIIyHdsUnE9UNbz3g40qJCHKNaWGvcC
|
|
|
4
4
|
pomcorn/descriptors/element.py,sha256=jSYxEUqKdAIEHf_zL9m6udyO4QDR22Ivm37BOa-tdKc,4486
|
|
5
5
|
pomcorn/element.py,sha256=l8haq8F25CZSIBTFST5bCwNWq9eg0rbjeKjvEiwG3VI,12205
|
|
6
6
|
pomcorn/locators/__init__.py,sha256=eWAnv28EGwzF-NQTeB4jc-T3B3a0gMbBIiR4IbmTo1Q,760
|
|
7
|
-
pomcorn/locators/base_locators.py,sha256=
|
|
7
|
+
pomcorn/locators/base_locators.py,sha256=j5PpHevQrhuRFUEd21ABZkCg1sJWY1BTXCmuzWTaOE0,9746
|
|
8
8
|
pomcorn/locators/xpath_locators.py,sha256=zcGNIk5HX36TTauCApgX0csdobWj8QFZ_td4-9qkTgU,7461
|
|
9
9
|
pomcorn/page.py,sha256=AJLXffI6GFP6XN3vhoGGrUknzvJZzP6GBP7BLaGumX0,5824
|
|
10
10
|
pomcorn/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
pomcorn/waits_conditions.py,sha256=E8sLfBvIV2EO91Mm5KyKXB5IGEB9gUWza3XPE4_aCQE,3528
|
|
12
12
|
pomcorn/web_view.py,sha256=qt3Gpr9BMtV0tLp5sLlleSEqweh2PphHXlT02awf9SE,13585
|
|
13
|
-
pomcorn-0.
|
|
14
|
-
pomcorn-0.
|
|
15
|
-
pomcorn-0.
|
|
16
|
-
pomcorn-0.
|
|
13
|
+
pomcorn-0.9.0.dist-info/LICENSE,sha256=1vmhQNp1dDH8ksJ199LuG4oKz5D4ZvNccPcFckiG2S4,1091
|
|
14
|
+
pomcorn-0.9.0.dist-info/METADATA,sha256=fueO8PC2Ce5qz-_uE235DF9nV-SgswTp9XUtMP5tk9E,5880
|
|
15
|
+
pomcorn-0.9.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
16
|
+
pomcorn-0.9.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|