mops 3.0.0__tar.gz → 3.2.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.
- {mops-3.0.0 → mops-3.2.0}/PKG-INFO +2 -3
- {mops-3.0.0 → mops-3.2.0}/README.md +0 -1
- {mops-3.0.0 → mops-3.2.0}/mops/__init__.py +1 -1
- {mops-3.0.0 → mops-3.2.0}/mops/abstraction/driver_wrapper_abc.py +61 -55
- {mops-3.0.0 → mops-3.2.0}/mops/abstraction/element_abc.py +76 -39
- {mops-3.0.0 → mops-3.2.0}/mops/abstraction/mixin_abc.py +1 -1
- {mops-3.0.0 → mops-3.2.0}/mops/base/driver_wrapper.py +47 -43
- {mops-3.0.0 → mops-3.2.0}/mops/base/element.py +200 -46
- mops-3.2.0/mops/base/group.py +82 -0
- {mops-3.0.0 → mops-3.2.0}/mops/base/page.py +21 -11
- {mops-3.0.0 → mops-3.2.0}/mops/exceptions.py +7 -0
- {mops-3.0.0 → mops-3.2.0}/mops/js_scripts.py +24 -14
- {mops-3.0.0 → mops-3.2.0}/mops/mixins/driver_mixin.py +6 -6
- {mops-3.0.0 → mops-3.2.0}/mops/mixins/internal_mixin.py +10 -14
- mops-3.2.0/mops/mixins/objects/box.py +61 -0
- {mops-3.0.0 → mops-3.2.0}/mops/mixins/objects/driver.py +2 -0
- {mops-3.0.0 → mops-3.2.0}/mops/mixins/objects/location.py +2 -0
- mops-3.2.0/mops/mixins/objects/locator.py +42 -0
- mops-3.2.0/mops/mixins/objects/locator_type.py +28 -0
- mops-3.2.0/mops/mixins/objects/scrolls.py +17 -0
- {mops-3.0.0 → mops-3.2.0}/mops/mixins/objects/size.py +2 -0
- {mops-3.0.0 → mops-3.2.0}/mops/playwright/play_driver.py +81 -24
- {mops-3.0.0 → mops-3.2.0}/mops/playwright/play_element.py +20 -108
- {mops-3.0.0 → mops-3.2.0}/mops/selenium/core/core_driver.py +45 -23
- {mops-3.0.0 → mops-3.2.0}/mops/selenium/core/core_element.py +65 -132
- {mops-3.0.0 → mops-3.2.0}/mops/selenium/driver/mobile_driver.py +4 -4
- {mops-3.0.0 → mops-3.2.0}/mops/selenium/driver/web_driver.py +17 -12
- {mops-3.0.0 → mops-3.2.0}/mops/selenium/elements/mobile_element.py +4 -9
- {mops-3.0.0 → mops-3.2.0}/mops/selenium/elements/web_element.py +3 -7
- mops-3.2.0/mops/utils/decorators.py +130 -0
- {mops-3.0.0 → mops-3.2.0}/mops/utils/internal_utils.py +2 -36
- mops-3.2.0/mops/utils/selector_synchronizer.py +154 -0
- {mops-3.0.0 → mops-3.2.0}/mops/visual_comparison.py +101 -57
- {mops-3.0.0 → mops-3.2.0}/mops.egg-info/PKG-INFO +2 -3
- {mops-3.0.0 → mops-3.2.0}/mops.egg-info/SOURCES.txt +2 -1
- {mops-3.0.0 → mops-3.2.0}/mops.egg-info/requires.txt +1 -1
- {mops-3.0.0 → mops-3.2.0}/pyproject.toml +3 -3
- mops-3.0.0/mops/base/group.py +0 -57
- mops-3.0.0/mops/mixins/objects/box.py +0 -25
- mops-3.0.0/mops/mixins/objects/cut_box.py +0 -44
- mops-3.0.0/mops/mixins/objects/locator.py +0 -23
- mops-3.0.0/mops/mixins/objects/scrolls.py +0 -15
- mops-3.0.0/mops/utils/selector_synchronizer.py +0 -135
- {mops-3.0.0 → mops-3.2.0}/mops/abstraction/page_abc.py +0 -0
- {mops-3.0.0 → mops-3.2.0}/mops/keyboard_keys.py +0 -0
- {mops-3.0.0 → mops-3.2.0}/mops/mixins/native_context.py +0 -0
- {mops-3.0.0 → mops-3.2.0}/mops/mixins/objects/wait_result.py +0 -0
- {mops-3.0.0 → mops-3.2.0}/mops/playwright/play_page.py +0 -0
- {mops-3.0.0 → mops-3.2.0}/mops/selenium/core/core_page.py +0 -0
- {mops-3.0.0 → mops-3.2.0}/mops/selenium/pages/mobile_page.py +0 -0
- {mops-3.0.0 → mops-3.2.0}/mops/selenium/pages/web_page.py +0 -0
- {mops-3.0.0 → mops-3.2.0}/mops/selenium/sel_utils.py +0 -0
- {mops-3.0.0 → mops-3.2.0}/mops/shared_utils.py +0 -0
- {mops-3.0.0 → mops-3.2.0}/mops/utils/logs.py +0 -0
- {mops-3.0.0 → mops-3.2.0}/mops/utils/previous_object_driver.py +0 -0
- {mops-3.0.0 → mops-3.2.0}/mops.egg-info/dependency_links.txt +0 -0
- {mops-3.0.0 → mops-3.2.0}/mops.egg-info/top_level.txt +0 -0
- {mops-3.0.0 → mops-3.2.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mops
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: Wrapper of Selenium, Appium and Playwright with single API
|
|
5
5
|
Author-email: Podolian Vladimir <vladimir.podolyan64@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -22,7 +22,7 @@ Classifier: Topic :: Software Development :: Testing :: Acceptance
|
|
|
22
22
|
Requires-Python: >=3.8
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
Requires-Dist: Appium-Python-Client>=3.1.0
|
|
25
|
-
Requires-Dist: playwright>=1.
|
|
25
|
+
Requires-Dist: playwright>=1.48.0
|
|
26
26
|
Requires-Dist: selenium>=4.12.0
|
|
27
27
|
Requires-Dist: numpy>=2.0.1; python_version >= "3.11"
|
|
28
28
|
Requires-Dist: numpy<2.0.0,>=1.24.2; python_version >= "3.8" and python_version <= "3.10"
|
|
@@ -85,7 +85,6 @@ process, giving you the flexibility and power to automate complex testing scenar
|
|
|
85
85
|
## Installation and usage
|
|
86
86
|
For information on installation and usage, please refer to our **[ReadTheDocs documentation](https://mops.readthedocs.io)**. Check it out for more details.
|
|
87
87
|
|
|
88
|
-
|
|
89
88
|
## Contributing
|
|
90
89
|
|
|
91
90
|
Mops is an open-source project, and we welcome contributions from the community. If you'd like to contribute, please open an pull request from your fork
|
|
@@ -50,7 +50,6 @@ process, giving you the flexibility and power to automate complex testing scenar
|
|
|
50
50
|
## Installation and usage
|
|
51
51
|
For information on installation and usage, please refer to our **[ReadTheDocs documentation](https://mops.readthedocs.io)**. Check it out for more details.
|
|
52
52
|
|
|
53
|
-
|
|
54
53
|
## Contributing
|
|
55
54
|
|
|
56
55
|
Mops is an open-source project, and we welcome contributions from the community. If you'd like to contribute, please open an pull request from your fork
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = '3.
|
|
1
|
+
__version__ = '3.2.0'
|
|
2
2
|
__project_name__ = 'mops'
|
|
@@ -6,7 +6,7 @@ from typing import List, Union, Any, Tuple, TYPE_CHECKING
|
|
|
6
6
|
|
|
7
7
|
from playwright.sync_api import Page as PlaywrightPage
|
|
8
8
|
|
|
9
|
-
from mops.mixins.objects.
|
|
9
|
+
from mops.mixins.objects.box import Box
|
|
10
10
|
from selenium.webdriver.common.alert import Alert
|
|
11
11
|
from PIL import Image
|
|
12
12
|
|
|
@@ -95,14 +95,6 @@ class DriverWrapperABC(ABC):
|
|
|
95
95
|
"""
|
|
96
96
|
raise NotImplementedError()
|
|
97
97
|
|
|
98
|
-
def get_inner_window_size(self) -> Size:
|
|
99
|
-
"""
|
|
100
|
-
Retrieve the inner size of the driver window.
|
|
101
|
-
|
|
102
|
-
:return: :class:`Size` - An object representing the window's dimensions.
|
|
103
|
-
"""
|
|
104
|
-
raise NotImplementedError()
|
|
105
|
-
|
|
106
98
|
def wait(self, timeout: Union[int, float] = WAIT_UNIT) -> DriverWrapper:
|
|
107
99
|
"""
|
|
108
100
|
Pauses the execution for a specified amount of time.
|
|
@@ -110,7 +102,7 @@ class DriverWrapperABC(ABC):
|
|
|
110
102
|
:param timeout: The time to sleep in seconds (can be an integer or float).
|
|
111
103
|
:type timeout: typing.Union[int, float]
|
|
112
104
|
|
|
113
|
-
:return: :obj
|
|
105
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
114
106
|
"""
|
|
115
107
|
raise NotImplementedError()
|
|
116
108
|
|
|
@@ -122,7 +114,7 @@ class DriverWrapperABC(ABC):
|
|
|
122
114
|
:type url: str
|
|
123
115
|
:param silent: If :obj:`True`, suppresses logging.
|
|
124
116
|
:type silent: bool
|
|
125
|
-
:return: :obj
|
|
117
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
126
118
|
"""
|
|
127
119
|
raise NotImplementedError()
|
|
128
120
|
|
|
@@ -155,7 +147,7 @@ class DriverWrapperABC(ABC):
|
|
|
155
147
|
"""
|
|
156
148
|
Reload the current page.
|
|
157
149
|
|
|
158
|
-
:return: :obj
|
|
150
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
159
151
|
"""
|
|
160
152
|
raise NotImplementedError()
|
|
161
153
|
|
|
@@ -163,7 +155,7 @@ class DriverWrapperABC(ABC):
|
|
|
163
155
|
"""
|
|
164
156
|
Navigate forward in the browser.
|
|
165
157
|
|
|
166
|
-
:return: :obj
|
|
158
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
167
159
|
"""
|
|
168
160
|
raise NotImplementedError()
|
|
169
161
|
|
|
@@ -171,7 +163,7 @@ class DriverWrapperABC(ABC):
|
|
|
171
163
|
"""
|
|
172
164
|
Navigate backward in the browser.
|
|
173
165
|
|
|
174
|
-
:return: :obj
|
|
166
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
175
167
|
"""
|
|
176
168
|
raise NotImplementedError()
|
|
177
169
|
|
|
@@ -183,7 +175,7 @@ class DriverWrapperABC(ABC):
|
|
|
183
175
|
|
|
184
176
|
:param cookies: A list of dictionaries, each containing cookie data.
|
|
185
177
|
:type cookies: typing.List[dict]
|
|
186
|
-
:return: :obj
|
|
178
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
187
179
|
"""
|
|
188
180
|
raise NotImplementedError()
|
|
189
181
|
|
|
@@ -191,20 +183,15 @@ class DriverWrapperABC(ABC):
|
|
|
191
183
|
"""
|
|
192
184
|
Delete all cookies in the current session.
|
|
193
185
|
|
|
194
|
-
:return: :obj
|
|
186
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
195
187
|
"""
|
|
196
188
|
raise NotImplementedError()
|
|
197
189
|
|
|
198
190
|
def delete_cookie(self, name: str) -> DriverWrapper:
|
|
199
191
|
"""
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
Note: Playwright does not support deleting specific cookies:
|
|
203
|
-
https://github.com/microsoft/playwright/issues/10143
|
|
204
|
-
|
|
205
|
-
Todo: Fixed in playwright 1.43.0
|
|
192
|
+
Delete a cookie by name.
|
|
206
193
|
|
|
207
|
-
:return: :obj
|
|
194
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
208
195
|
"""
|
|
209
196
|
raise NotImplementedError()
|
|
210
197
|
|
|
@@ -219,19 +206,19 @@ class DriverWrapperABC(ABC):
|
|
|
219
206
|
|
|
220
207
|
def switch_to_frame(self, frame: Element) -> DriverWrapper:
|
|
221
208
|
"""
|
|
222
|
-
|
|
209
|
+
Switch to a specified frame.
|
|
223
210
|
|
|
224
211
|
:param frame: The frame element to switch to.
|
|
225
212
|
:type frame: Element
|
|
226
|
-
:return: :obj
|
|
213
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
227
214
|
"""
|
|
228
215
|
raise NotImplementedError()
|
|
229
216
|
|
|
230
217
|
def switch_to_default_content(self) -> DriverWrapper:
|
|
231
218
|
"""
|
|
232
|
-
|
|
219
|
+
Switch back to the default content from a frame.
|
|
233
220
|
|
|
234
|
-
:return: :obj
|
|
221
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
235
222
|
"""
|
|
236
223
|
raise NotImplementedError()
|
|
237
224
|
|
|
@@ -266,19 +253,38 @@ class DriverWrapperABC(ABC):
|
|
|
266
253
|
|
|
267
254
|
:param timeout: The timeout duration to set, in seconds.
|
|
268
255
|
:type timeout: int
|
|
269
|
-
:return: :obj
|
|
256
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
257
|
+
"""
|
|
258
|
+
raise NotImplementedError()
|
|
259
|
+
|
|
260
|
+
def set_window_size(self, size: Size) -> DriverWrapper:
|
|
261
|
+
"""
|
|
262
|
+
Set the inner window size (viewport) of the current browser context.
|
|
263
|
+
|
|
264
|
+
:param size: The desired inner window size as a :class:`.Size` object.
|
|
265
|
+
:return: The current instance of :obj:`.DriverWrapper`.
|
|
266
|
+
"""
|
|
267
|
+
raise NotImplementedError()
|
|
268
|
+
|
|
269
|
+
def get_inner_window_size(self) -> Size:
|
|
270
|
+
"""
|
|
271
|
+
Retrieve the inner window size (viewport) of the current browser context.
|
|
272
|
+
|
|
273
|
+
:return: The size of the inner window as a :class:`.Size` object.
|
|
270
274
|
"""
|
|
271
275
|
raise NotImplementedError()
|
|
272
276
|
|
|
273
|
-
def
|
|
277
|
+
def get_window_size(self) -> Size:
|
|
274
278
|
"""
|
|
275
|
-
|
|
279
|
+
Retrieve the outer window size of the current browser context.
|
|
280
|
+
|
|
281
|
+
.. note::
|
|
282
|
+
Playwright behaves differently in headless mode, where the reported window
|
|
283
|
+
size may not reflect the actual dimensions.
|
|
284
|
+
In contrast, Appium does not support retrieving the window size in the
|
|
285
|
+
same way as traditional web browsers.
|
|
276
286
|
|
|
277
|
-
:
|
|
278
|
-
:type width: int
|
|
279
|
-
:param height: The height, in pixels, to set the window to.
|
|
280
|
-
:type height: int
|
|
281
|
-
:return: :obj:`DriverWrapper` - The current instance of the driver wrapper.
|
|
287
|
+
:return: The size of the outer window as a :class:`.Size` object.
|
|
282
288
|
"""
|
|
283
289
|
raise NotImplementedError()
|
|
284
290
|
|
|
@@ -308,9 +314,9 @@ class DriverWrapperABC(ABC):
|
|
|
308
314
|
name_suffix: str = '',
|
|
309
315
|
threshold: Union[int, float] = None,
|
|
310
316
|
delay: Union[int, float] = None,
|
|
311
|
-
remove: Union[
|
|
312
|
-
cut_box:
|
|
313
|
-
hide: Union[
|
|
317
|
+
remove: Union[Element, List[Element]] = None,
|
|
318
|
+
cut_box: Box = None,
|
|
319
|
+
hide: Union[Element, List[Element]] = None,
|
|
314
320
|
) -> None:
|
|
315
321
|
"""
|
|
316
322
|
Asserts that the given screenshot matches the currently taken screenshot.
|
|
@@ -333,9 +339,9 @@ class DriverWrapperABC(ABC):
|
|
|
333
339
|
:param remove: :class:`Element` to remove from the screenshot.
|
|
334
340
|
Can be a single element or a list of elements.
|
|
335
341
|
:type remove: typing.Optional[Element or typing.List[Element]]
|
|
336
|
-
:param cut_box: A `
|
|
342
|
+
:param cut_box: A :class:`.Box` specifying a region to cut from the screenshot.
|
|
337
343
|
If :obj:`None`, no region is cut.
|
|
338
|
-
:type cut_box: typing.Optional[
|
|
344
|
+
:type cut_box: typing.Optional[Box]
|
|
339
345
|
:param hide: :class:`Element` to hide in the screenshot.
|
|
340
346
|
Can be a single element or a list of elements.
|
|
341
347
|
:type hide: typing.Optional[Element or typing.List[Element]]
|
|
@@ -350,9 +356,9 @@ class DriverWrapperABC(ABC):
|
|
|
350
356
|
name_suffix: str = '',
|
|
351
357
|
threshold: Union[int, float] = None,
|
|
352
358
|
delay: Union[int, float] = None,
|
|
353
|
-
remove: Union[
|
|
354
|
-
cut_box:
|
|
355
|
-
hide: Union[
|
|
359
|
+
remove: Union[Element, List[Element]] = None,
|
|
360
|
+
cut_box: Box = None,
|
|
361
|
+
hide: Union[Element, List[Element]] = None,
|
|
356
362
|
) -> Tuple[bool, str]:
|
|
357
363
|
"""
|
|
358
364
|
Compares the currently taken screenshot to the expected screenshot and returns a result.
|
|
@@ -374,9 +380,9 @@ class DriverWrapperABC(ABC):
|
|
|
374
380
|
:type delay: typing.Optional[int or float]
|
|
375
381
|
:param remove: :class:`Element` to remove from the screenshot.
|
|
376
382
|
:type remove: typing.Optional[Element or typing.List[Element]]
|
|
377
|
-
:param cut_box: A `
|
|
383
|
+
:param cut_box: A :class:`.Box` specifying a region to cut from the screenshot.
|
|
378
384
|
If :obj:`None`, no region is cut.
|
|
379
|
-
:type cut_box: typing.Optional[
|
|
385
|
+
:type cut_box: typing.Optional[Box]
|
|
380
386
|
:param hide: :class:`Element` to hide in the screenshot.
|
|
381
387
|
Can be a single element or a list of elements.
|
|
382
388
|
:return: :class:`typing.Tuple` (:class:`bool`, :class:`str`) - result state and result message
|
|
@@ -417,7 +423,7 @@ class DriverWrapperABC(ABC):
|
|
|
417
423
|
"""
|
|
418
424
|
Selenium/Playwright only: Create a new tab and switch to it.
|
|
419
425
|
|
|
420
|
-
:return: :obj
|
|
426
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper, now switched to the new tab.
|
|
421
427
|
"""
|
|
422
428
|
raise NotImplementedError()
|
|
423
429
|
|
|
@@ -425,7 +431,7 @@ class DriverWrapperABC(ABC):
|
|
|
425
431
|
"""
|
|
426
432
|
Selenium/Playwright only: Switch back to the original tab.
|
|
427
433
|
|
|
428
|
-
:return: :obj
|
|
434
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper, now switched to the original tab.
|
|
429
435
|
"""
|
|
430
436
|
raise NotImplementedError()
|
|
431
437
|
|
|
@@ -435,7 +441,7 @@ class DriverWrapperABC(ABC):
|
|
|
435
441
|
|
|
436
442
|
:param tab: The index of the tab to switch to, starting from 1. Default is the latest tab.
|
|
437
443
|
:type tab: int
|
|
438
|
-
:return: :obj
|
|
444
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper, now switched to the specified tab.
|
|
439
445
|
"""
|
|
440
446
|
raise NotImplementedError()
|
|
441
447
|
|
|
@@ -443,7 +449,7 @@ class DriverWrapperABC(ABC):
|
|
|
443
449
|
"""
|
|
444
450
|
Selenium/Playwright only: Close all tabs except the original.
|
|
445
451
|
|
|
446
|
-
:return: :obj
|
|
452
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper,
|
|
447
453
|
with all tabs except the original closed.
|
|
448
454
|
"""
|
|
449
455
|
raise NotImplementedError()
|
|
@@ -458,7 +464,7 @@ class DriverWrapperABC(ABC):
|
|
|
458
464
|
:type y: int
|
|
459
465
|
:param silent: If :obj:`True`, suppresses the log message. Default is :obj:`False`.
|
|
460
466
|
:type silent: bool
|
|
461
|
-
:return: :obj
|
|
467
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
462
468
|
"""
|
|
463
469
|
raise NotImplementedError()
|
|
464
470
|
|
|
@@ -516,7 +522,7 @@ class DriverWrapperABC(ABC):
|
|
|
516
522
|
"""
|
|
517
523
|
Appium only: Switch to the native app context.
|
|
518
524
|
|
|
519
|
-
:return: :obj
|
|
525
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper, now in the native app context.
|
|
520
526
|
"""
|
|
521
527
|
raise NotImplementedError()
|
|
522
528
|
|
|
@@ -524,7 +530,7 @@ class DriverWrapperABC(ABC):
|
|
|
524
530
|
"""
|
|
525
531
|
Appium only: Switch to the web app context.
|
|
526
532
|
|
|
527
|
-
:return: :obj
|
|
533
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper, now in the web app context.
|
|
528
534
|
"""
|
|
529
535
|
raise NotImplementedError()
|
|
530
536
|
|
|
@@ -575,7 +581,7 @@ class DriverWrapperABC(ABC):
|
|
|
575
581
|
Appium only: Hide the keyboard on a real device.
|
|
576
582
|
|
|
577
583
|
:param kwargs: Additional arguments passed to the `Keyboard.hide_keyboard` method.
|
|
578
|
-
:return: :obj
|
|
584
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
579
585
|
"""
|
|
580
586
|
raise NotImplementedError()
|
|
581
587
|
|
|
@@ -611,7 +617,7 @@ class DriverWrapperABC(ABC):
|
|
|
611
617
|
"""
|
|
612
618
|
Appium/Selenium only: Wait for an alert, switch to it, and click accept.
|
|
613
619
|
|
|
614
|
-
:return: :obj
|
|
620
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
615
621
|
"""
|
|
616
622
|
raise NotImplementedError()
|
|
617
623
|
|
|
@@ -619,7 +625,7 @@ class DriverWrapperABC(ABC):
|
|
|
619
625
|
"""
|
|
620
626
|
Appium/Selenium only: Wait for an alert, switch to it, and click dismiss.
|
|
621
627
|
|
|
622
|
-
:return: :obj
|
|
628
|
+
:return: :obj:`.DriverWrapper` - The current instance of the driver wrapper.
|
|
623
629
|
"""
|
|
624
630
|
raise NotImplementedError()
|
|
625
631
|
|
|
@@ -5,7 +5,8 @@ from typing import Union, Any, List, Tuple, Optional, TYPE_CHECKING
|
|
|
5
5
|
|
|
6
6
|
from PIL.Image import Image
|
|
7
7
|
from appium.webdriver.extensions.location import Location
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
from mops.mixins.objects.box import Box
|
|
9
10
|
from mops.mixins.objects.scrolls import ScrollTo, ScrollTypes
|
|
10
11
|
from selenium.webdriver.remote.webelement import WebElement as SeleniumWebElement
|
|
11
12
|
from appium.webdriver.webelement import WebElement as AppiumWebElement
|
|
@@ -17,16 +18,16 @@ from mops.mixins.objects.size import Size
|
|
|
17
18
|
from mops.utils.internal_utils import WAIT_EL, QUARTER_WAIT_EL
|
|
18
19
|
|
|
19
20
|
if TYPE_CHECKING:
|
|
21
|
+
from mops.mixins.objects.locator import Locator
|
|
20
22
|
from mops.base.element import Element
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
class ElementABC(MixinABC, ABC):
|
|
24
26
|
|
|
25
|
-
locator: str
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
wait: bool = None
|
|
27
|
+
locator: Union[Locator, str]
|
|
28
|
+
name: str = ''
|
|
29
|
+
parent: Union[Any, bool, None] = None
|
|
30
|
+
wait: Optional[bool] = None
|
|
30
31
|
|
|
31
32
|
@property
|
|
32
33
|
def element(self) -> Union[SeleniumWebElement, AppiumWebElement, PlayWebElement]:
|
|
@@ -51,7 +52,7 @@ class ElementABC(MixinABC, ABC):
|
|
|
51
52
|
raise NotImplementedError()
|
|
52
53
|
|
|
53
54
|
@property
|
|
54
|
-
def all_elements(self) -> Union[
|
|
55
|
+
def all_elements(self) -> Union[List[Element], List[Any]]:
|
|
55
56
|
"""
|
|
56
57
|
Returns a list of all matching elements.
|
|
57
58
|
|
|
@@ -142,10 +143,19 @@ class ElementABC(MixinABC, ABC):
|
|
|
142
143
|
"""
|
|
143
144
|
raise NotImplementedError()
|
|
144
145
|
|
|
145
|
-
def wait_visibility(
|
|
146
|
+
def wait_visibility(
|
|
147
|
+
self,
|
|
148
|
+
*,
|
|
149
|
+
timeout: int = WAIT_EL,
|
|
150
|
+
silent: bool = False,
|
|
151
|
+
continuous: Union[bool, int, float] = False,
|
|
152
|
+
) -> Element:
|
|
146
153
|
"""
|
|
147
154
|
Waits until the element becomes visible.
|
|
148
|
-
|
|
155
|
+
**Note:** The method requires the use of named arguments.
|
|
156
|
+
|
|
157
|
+
A continuous visibility verification may be applied for given
|
|
158
|
+
or default amount of time after the first condition is met.
|
|
149
159
|
|
|
150
160
|
**Selenium:**
|
|
151
161
|
|
|
@@ -162,14 +172,26 @@ class ElementABC(MixinABC, ABC):
|
|
|
162
172
|
:type timeout: int
|
|
163
173
|
:param silent: If :obj:`True`, suppresses logging.
|
|
164
174
|
:type silent: bool
|
|
175
|
+
:param continuous: If :obj:`True`, a continuous visibility verification applied for another 2.5 seconds.
|
|
176
|
+
An :obj:`int` or :obj:`float` modifies the continuous wait timeout.
|
|
177
|
+
:type continuous: typing.Union[int, float, bool]
|
|
165
178
|
:return: :class:`Element`
|
|
166
179
|
"""
|
|
167
180
|
raise NotImplementedError()
|
|
168
181
|
|
|
169
|
-
def wait_hidden(
|
|
182
|
+
def wait_hidden(
|
|
183
|
+
self,
|
|
184
|
+
*,
|
|
185
|
+
timeout: int = WAIT_EL,
|
|
186
|
+
silent: bool = False,
|
|
187
|
+
continuous: Union[bool, int, float] = False,
|
|
188
|
+
) -> Element:
|
|
170
189
|
"""
|
|
171
190
|
Waits until the element becomes hidden.
|
|
172
|
-
|
|
191
|
+
**Note:** The method requires the use of named arguments.
|
|
192
|
+
|
|
193
|
+
A continuous invisibility verification may be applied for given
|
|
194
|
+
or default amount of time after the first condition is met.
|
|
173
195
|
|
|
174
196
|
**Selenium:**
|
|
175
197
|
|
|
@@ -186,6 +208,9 @@ class ElementABC(MixinABC, ABC):
|
|
|
186
208
|
:type timeout: int
|
|
187
209
|
:param silent: If :obj:`True`, suppresses logging.
|
|
188
210
|
:type silent: bool
|
|
211
|
+
:param continuous: If :obj:`True`, a continuous invisibility verification applied for another 2.5 seconds.
|
|
212
|
+
An :obj:`int` or :obj:`float` modifies the continuous wait timeout.
|
|
213
|
+
:type continuous: typing.Union[int, float, bool]
|
|
189
214
|
:return: :class:`Element`
|
|
190
215
|
"""
|
|
191
216
|
raise NotImplementedError()
|
|
@@ -193,7 +218,7 @@ class ElementABC(MixinABC, ABC):
|
|
|
193
218
|
def wait_availability(self, *, timeout: int = WAIT_EL, silent: bool = False) -> Element:
|
|
194
219
|
"""
|
|
195
220
|
Waits until the element becomes available in DOM tree. \n
|
|
196
|
-
|
|
221
|
+
**Note:** The method requires the use of named arguments.
|
|
197
222
|
|
|
198
223
|
**Selenium:**
|
|
199
224
|
|
|
@@ -374,7 +399,7 @@ class ElementABC(MixinABC, ABC):
|
|
|
374
399
|
"""
|
|
375
400
|
Get the size of the current element, including width and height.
|
|
376
401
|
|
|
377
|
-
:return: :class
|
|
402
|
+
:return: :class:`.Size` - An object representing the element's dimensions.
|
|
378
403
|
"""
|
|
379
404
|
raise NotImplementedError()
|
|
380
405
|
|
|
@@ -383,7 +408,7 @@ class ElementABC(MixinABC, ABC):
|
|
|
383
408
|
"""
|
|
384
409
|
Get the location of the current element, including the x and y coordinates.
|
|
385
410
|
|
|
386
|
-
:return: :class
|
|
411
|
+
:return: :class:`.Location` - An object representing the element's position.
|
|
387
412
|
"""
|
|
388
413
|
raise NotImplementedError()
|
|
389
414
|
|
|
@@ -529,7 +554,7 @@ class ElementABC(MixinABC, ABC):
|
|
|
529
554
|
:param expected_text: The text to wait for. :obj:`None` - any text; :class:`str` - expected text.
|
|
530
555
|
:type expected_text: typing.Optional[str]
|
|
531
556
|
:param timeout: The maximum time to wait for the condition (in seconds). Default: :obj:`WAIT_EL`.
|
|
532
|
-
:type timeout: int
|
|
557
|
+
:type timeout: typing.Union[int, float]
|
|
533
558
|
:param silent: If :obj:`True`, suppresses logging.
|
|
534
559
|
:type silent: bool
|
|
535
560
|
:return: :class:`Element`
|
|
@@ -562,7 +587,7 @@ class ElementABC(MixinABC, ABC):
|
|
|
562
587
|
:param expected_value: The value to waiting for. :obj:`None` - any value; :class:`str` - expected value.
|
|
563
588
|
:type expected_value: typing.Optional[str]
|
|
564
589
|
:param timeout: The maximum time to wait for the condition (in seconds). Default: :obj:`WAIT_EL`.
|
|
565
|
-
:type timeout: int
|
|
590
|
+
:type timeout: typing.Union[int, float]
|
|
566
591
|
:param silent: If :obj:`True`, suppresses logging.
|
|
567
592
|
:type silent: bool
|
|
568
593
|
:return: :class:`Element`
|
|
@@ -573,12 +598,15 @@ class ElementABC(MixinABC, ABC):
|
|
|
573
598
|
self,
|
|
574
599
|
*,
|
|
575
600
|
timeout: Union[int, float] = QUARTER_WAIT_EL,
|
|
576
|
-
silent: bool = False
|
|
601
|
+
silent: bool = False,
|
|
602
|
+
continuous: Union[bool, int, float] = False,
|
|
577
603
|
) -> Element:
|
|
578
604
|
"""
|
|
579
605
|
Wait for the element to become visible, without raising an error if it does not.
|
|
606
|
+
**Note:** The method requires the use of named arguments.
|
|
580
607
|
|
|
581
|
-
|
|
608
|
+
A continuous visibility verification may be applied for given
|
|
609
|
+
or default amount of time after the first condition is met.
|
|
582
610
|
|
|
583
611
|
**Selenium & Playwright:**
|
|
584
612
|
|
|
@@ -592,9 +620,12 @@ class ElementABC(MixinABC, ABC):
|
|
|
592
620
|
with each iteration during the waiting process.
|
|
593
621
|
|
|
594
622
|
:param timeout: The maximum time to wait for the condition (in seconds). Default: :obj:`QUARTER_WAIT_EL`.
|
|
595
|
-
:type timeout: int
|
|
623
|
+
:type timeout: typing.Union[int, float]
|
|
596
624
|
:param silent: If :obj:`True`, suppresses logging.
|
|
597
625
|
:type silent: bool
|
|
626
|
+
:param continuous: If :obj:`True`, a continuous visibility verification applied for another 2.5 seconds.
|
|
627
|
+
An :obj:`int` or :obj:`float` modifies the continuous wait timeout.
|
|
628
|
+
:type continuous: typing.Union[int, float, bool]
|
|
598
629
|
:return: :class:`Element`
|
|
599
630
|
"""
|
|
600
631
|
raise NotImplementedError()
|
|
@@ -603,12 +634,15 @@ class ElementABC(MixinABC, ABC):
|
|
|
603
634
|
self,
|
|
604
635
|
*,
|
|
605
636
|
timeout: Union[int, float] = QUARTER_WAIT_EL,
|
|
606
|
-
silent: bool = False
|
|
637
|
+
silent: bool = False,
|
|
638
|
+
continuous: Union[bool, int, float] = False,
|
|
607
639
|
) -> Element:
|
|
608
640
|
"""
|
|
609
641
|
Wait for the element to become hidden, without raising an error if it does not.
|
|
642
|
+
**Note:** The method requires the use of named arguments.
|
|
610
643
|
|
|
611
|
-
|
|
644
|
+
A continuous invisibility verification may be applied for given
|
|
645
|
+
or default amount of time after the first condition is met.
|
|
612
646
|
|
|
613
647
|
**Selenium & Playwright:**
|
|
614
648
|
|
|
@@ -622,9 +656,12 @@ class ElementABC(MixinABC, ABC):
|
|
|
622
656
|
with each iteration during the waiting process.
|
|
623
657
|
|
|
624
658
|
:param timeout: The maximum time to wait for the condition (in seconds). Default: :obj:`QUARTER_WAIT_EL`.
|
|
625
|
-
:type timeout: int
|
|
659
|
+
:type timeout: typing.Union[int, float]
|
|
626
660
|
:param silent: If :obj:`True`, suppresses logging.
|
|
627
661
|
:type silent: bool
|
|
662
|
+
:param continuous: If :obj:`True`, a continuous invisibility verification applied for another 2.5 seconds.
|
|
663
|
+
An :obj:`int` or :obj:`float` modifies the continuous wait timeout.
|
|
664
|
+
:type continuous: typing.Union[int, float, bool]
|
|
628
665
|
:return: :class:`Element`
|
|
629
666
|
"""
|
|
630
667
|
raise NotImplementedError()
|
|
@@ -647,7 +684,7 @@ class ElementABC(MixinABC, ABC):
|
|
|
647
684
|
with each iteration during the waiting process.
|
|
648
685
|
|
|
649
686
|
:param timeout: The maximum time to wait for the condition (in seconds). Default: :obj:`WAIT_EL`.
|
|
650
|
-
:type timeout: int
|
|
687
|
+
:type timeout: typing.Union[int, float]
|
|
651
688
|
:param silent: If :obj:`True`, suppresses logging.
|
|
652
689
|
:type silent: bool
|
|
653
690
|
:return: :class:`Element`
|
|
@@ -687,7 +724,7 @@ class ElementABC(MixinABC, ABC):
|
|
|
687
724
|
silent: bool = False
|
|
688
725
|
) -> Element:
|
|
689
726
|
"""
|
|
690
|
-
Wait until element size will be equal to given :class
|
|
727
|
+
Wait until element size will be equal to given :class:`.Size` object
|
|
691
728
|
|
|
692
729
|
**Note:** The method requires the use of named arguments except ``expected_size``.
|
|
693
730
|
|
|
@@ -703,9 +740,9 @@ class ElementABC(MixinABC, ABC):
|
|
|
703
740
|
with each iteration during the waiting process.
|
|
704
741
|
|
|
705
742
|
:param expected_size: expected element size
|
|
706
|
-
:type expected_size: :class
|
|
743
|
+
:type expected_size: :class:`.Size`
|
|
707
744
|
:param timeout: The maximum time to wait for the condition (in seconds). Default: :obj:`WAIT_EL`.
|
|
708
|
-
:type timeout: int
|
|
745
|
+
:type timeout: typing.Union[int, float]
|
|
709
746
|
:param silent: If :obj:`True`, suppresses logging.
|
|
710
747
|
:type silent: bool
|
|
711
748
|
:return: :class:`Element`
|
|
@@ -748,12 +785,12 @@ class ElementABC(MixinABC, ABC):
|
|
|
748
785
|
"""
|
|
749
786
|
Scrolls the element into view using a JavaScript script.
|
|
750
787
|
|
|
751
|
-
:param block: The scrolling block alignment. One of the :class
|
|
788
|
+
:param block: The scrolling block alignment. One of the :class:`.ScrollTo` options.
|
|
752
789
|
:type block: ScrollTo
|
|
753
|
-
:param behavior: The scrolling behavior. One of the :class
|
|
790
|
+
:param behavior: The scrolling behavior. One of the :class:`.ScrollTypes` options.
|
|
754
791
|
:type behavior: ScrollTypes
|
|
755
792
|
:param sleep: Delay in seconds after scrolling. Can be an integer or a float.
|
|
756
|
-
:type sleep: int
|
|
793
|
+
:type sleep: typing.Union[int, float]
|
|
757
794
|
:param silent: If :obj:`True`, suppresses logging.
|
|
758
795
|
:type silent: bool
|
|
759
796
|
:return: :class:`Element`
|
|
@@ -770,7 +807,7 @@ class ElementABC(MixinABC, ABC):
|
|
|
770
807
|
scroll: bool = False,
|
|
771
808
|
remove: Union[Element, List[Element]] = None,
|
|
772
809
|
fill_background: Union[str, bool] = False,
|
|
773
|
-
cut_box:
|
|
810
|
+
cut_box: Box = None,
|
|
774
811
|
hide: Union[Element, List[Element]] = None,
|
|
775
812
|
) -> None:
|
|
776
813
|
"""
|
|
@@ -787,10 +824,10 @@ class ElementABC(MixinABC, ABC):
|
|
|
787
824
|
:type name_suffix: str
|
|
788
825
|
:param threshold: The acceptable threshold for comparing screenshots.
|
|
789
826
|
If :obj:`None` - takes default threshold or calculate its automatically based on screenshot size.
|
|
790
|
-
:type threshold: typing.Optional[int
|
|
827
|
+
:type threshold: typing.Optional[int, float]
|
|
791
828
|
:param delay: The delay in seconds before taking the screenshot.
|
|
792
829
|
If :obj:`None` - takes default delay.
|
|
793
|
-
:type delay: typing.Optional[int
|
|
830
|
+
:type delay: typing.Optional[int, float]
|
|
794
831
|
:param scroll: Whether to scroll to the element before taking the screenshot.
|
|
795
832
|
:type scroll: bool
|
|
796
833
|
:param remove: :class:`Element` to remove from the screenshot.
|
|
@@ -799,9 +836,9 @@ class ElementABC(MixinABC, ABC):
|
|
|
799
836
|
:param fill_background: The color to fill the background.
|
|
800
837
|
If :obj:`True`, uses a default color (black). If a :class:`str`, uses the specified color.
|
|
801
838
|
:type fill_background: typing.Optional[str or bool]
|
|
802
|
-
:param cut_box: A `
|
|
839
|
+
:param cut_box: A :class:`.Box` specifying a region to cut from the screenshot.
|
|
803
840
|
If :obj:`None`, no region is cut.
|
|
804
|
-
:type cut_box: typing.Optional[
|
|
841
|
+
:type cut_box: typing.Optional[Box]
|
|
805
842
|
:param hide: :class:`Element` to hide in the screenshot.
|
|
806
843
|
Can be a single element or a list of elements.
|
|
807
844
|
:type hide: typing.Optional[Element or typing.List[Element]]
|
|
@@ -819,7 +856,7 @@ class ElementABC(MixinABC, ABC):
|
|
|
819
856
|
scroll: bool = False,
|
|
820
857
|
remove: Union[Element, List[Element]] = None,
|
|
821
858
|
fill_background: Union[str, bool] = False,
|
|
822
|
-
cut_box:
|
|
859
|
+
cut_box: Box = None,
|
|
823
860
|
hide: Union[Element, List[Element]] = None,
|
|
824
861
|
) -> Tuple[bool, str]:
|
|
825
862
|
"""
|
|
@@ -836,10 +873,10 @@ class ElementABC(MixinABC, ABC):
|
|
|
836
873
|
:type name_suffix: str
|
|
837
874
|
:param threshold: The acceptable threshold for comparing screenshots.
|
|
838
875
|
If :obj:`None` - takes default threshold or calculate its automatically based on screenshot size.
|
|
839
|
-
:type threshold: typing.Optional[int
|
|
876
|
+
:type threshold: typing.Optional[int, float]
|
|
840
877
|
:param delay: The delay in seconds before taking the screenshot.
|
|
841
878
|
If :obj:`None` - takes default delay.
|
|
842
|
-
:type delay: typing.Optional[int
|
|
879
|
+
:type delay: typing.Optional[int, float]
|
|
843
880
|
:param scroll: Whether to scroll to the element before taking the screenshot.
|
|
844
881
|
:type scroll: bool
|
|
845
882
|
:param remove: :class:`Element` to remove from the screenshot.
|
|
@@ -847,9 +884,9 @@ class ElementABC(MixinABC, ABC):
|
|
|
847
884
|
:param fill_background: The color to fill the background.
|
|
848
885
|
If :obj:`True`, uses a default color (black). If a :class:`str`, uses the specified color.
|
|
849
886
|
:type fill_background: typing.Optional[str or bool]
|
|
850
|
-
:param cut_box: A `
|
|
887
|
+
:param cut_box: A :class:`.Box` specifying a region to cut from the screenshot.
|
|
851
888
|
If :obj:`None`, no region is cut.
|
|
852
|
-
:type cut_box: typing.Optional[
|
|
889
|
+
:type cut_box: typing.Optional[Box]
|
|
853
890
|
:param hide: :class:`Element` to hide in the screenshot.
|
|
854
891
|
Can be a single element or a list of elements.
|
|
855
892
|
:return: :class:`typing.Tuple` (:class:`bool`, :class:`str`) - result state and result message
|
|
@@ -28,7 +28,7 @@ class MixinABC(ABC):
|
|
|
28
28
|
"""
|
|
29
29
|
Retrieves the driver wrapper instance.
|
|
30
30
|
|
|
31
|
-
:return: The current :
|
|
31
|
+
:return: The current :obj:`.DriverWrapper` instance that assigned for this object.
|
|
32
32
|
:rtype: DriverWrapper
|
|
33
33
|
"""
|
|
34
34
|
raise NotImplementedError()
|