osn-selenium 0.0.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.
Files changed (57) hide show
  1. osn_selenium/__init__.py +1 -0
  2. osn_selenium/browsers_handler/__init__.py +70 -0
  3. osn_selenium/browsers_handler/_windows.py +130 -0
  4. osn_selenium/browsers_handler/types.py +20 -0
  5. osn_selenium/captcha_workers/__init__.py +26 -0
  6. osn_selenium/dev_tools/__init__.py +1 -0
  7. osn_selenium/dev_tools/_types.py +22 -0
  8. osn_selenium/dev_tools/domains/__init__.py +63 -0
  9. osn_selenium/dev_tools/domains/abstract.py +378 -0
  10. osn_selenium/dev_tools/domains/fetch.py +1295 -0
  11. osn_selenium/dev_tools/domains_default/__init__.py +1 -0
  12. osn_selenium/dev_tools/domains_default/fetch.py +155 -0
  13. osn_selenium/dev_tools/errors.py +89 -0
  14. osn_selenium/dev_tools/logger.py +558 -0
  15. osn_selenium/dev_tools/manager.py +1551 -0
  16. osn_selenium/dev_tools/utils.py +509 -0
  17. osn_selenium/errors.py +16 -0
  18. osn_selenium/types.py +118 -0
  19. osn_selenium/webdrivers/BaseDriver/__init__.py +1 -0
  20. osn_selenium/webdrivers/BaseDriver/_utils.py +37 -0
  21. osn_selenium/webdrivers/BaseDriver/flags.py +644 -0
  22. osn_selenium/webdrivers/BaseDriver/protocols.py +2135 -0
  23. osn_selenium/webdrivers/BaseDriver/trio_wrapper.py +71 -0
  24. osn_selenium/webdrivers/BaseDriver/webdriver.py +2626 -0
  25. osn_selenium/webdrivers/Blink/__init__.py +1 -0
  26. osn_selenium/webdrivers/Blink/flags.py +1349 -0
  27. osn_selenium/webdrivers/Blink/protocols.py +330 -0
  28. osn_selenium/webdrivers/Blink/webdriver.py +637 -0
  29. osn_selenium/webdrivers/Chrome/__init__.py +1 -0
  30. osn_selenium/webdrivers/Chrome/flags.py +192 -0
  31. osn_selenium/webdrivers/Chrome/protocols.py +228 -0
  32. osn_selenium/webdrivers/Chrome/webdriver.py +394 -0
  33. osn_selenium/webdrivers/Edge/__init__.py +1 -0
  34. osn_selenium/webdrivers/Edge/flags.py +192 -0
  35. osn_selenium/webdrivers/Edge/protocols.py +228 -0
  36. osn_selenium/webdrivers/Edge/webdriver.py +394 -0
  37. osn_selenium/webdrivers/Yandex/__init__.py +1 -0
  38. osn_selenium/webdrivers/Yandex/flags.py +192 -0
  39. osn_selenium/webdrivers/Yandex/protocols.py +211 -0
  40. osn_selenium/webdrivers/Yandex/webdriver.py +350 -0
  41. osn_selenium/webdrivers/__init__.py +1 -0
  42. osn_selenium/webdrivers/_functions.py +504 -0
  43. osn_selenium/webdrivers/js_scripts/check_element_in_viewport.js +18 -0
  44. osn_selenium/webdrivers/js_scripts/get_document_scroll_size.js +4 -0
  45. osn_selenium/webdrivers/js_scripts/get_element_css.js +6 -0
  46. osn_selenium/webdrivers/js_scripts/get_element_rect_in_viewport.js +9 -0
  47. osn_selenium/webdrivers/js_scripts/get_random_element_point_in_viewport.js +59 -0
  48. osn_selenium/webdrivers/js_scripts/get_viewport_position.js +4 -0
  49. osn_selenium/webdrivers/js_scripts/get_viewport_rect.js +6 -0
  50. osn_selenium/webdrivers/js_scripts/get_viewport_size.js +4 -0
  51. osn_selenium/webdrivers/js_scripts/open_new_tab.js +1 -0
  52. osn_selenium/webdrivers/js_scripts/stop_window_loading.js +1 -0
  53. osn_selenium/webdrivers/types.py +390 -0
  54. osn_selenium-0.0.0.dist-info/METADATA +710 -0
  55. osn_selenium-0.0.0.dist-info/RECORD +57 -0
  56. osn_selenium-0.0.0.dist-info/WHEEL +5 -0
  57. osn_selenium-0.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,71 @@
1
+ from typing import Any, TYPE_CHECKING
2
+ from osn_selenium.webdrivers.BaseDriver._utils import trio_async_wrap
3
+
4
+
5
+ if TYPE_CHECKING:
6
+ from osn_selenium.webdrivers.BaseDriver.webdriver import BrowserWebDriver
7
+
8
+
9
+ class TrioBrowserWebDriverWrapper:
10
+ """
11
+ Wraps BrowserWebDriver methods for asynchronous execution using Trio.
12
+
13
+ This class acts as a proxy to a `BrowserWebDriver` instance. It intercepts
14
+ method calls and executes them in a separate thread using `trio.to_thread.run_sync`,
15
+ allowing synchronous WebDriver operations to be called from asynchronous Trio code
16
+ without blocking the event loop. Properties and non-callable attributes are accessed directly.
17
+
18
+ Attributes:
19
+ _webdriver (BrowserWebDriver): The underlying synchronous BrowserWebDriver instance.
20
+ _excluding_functions (list[str]): A list of attribute names on the wrapped object
21
+ that should *not* be accessible through this wrapper,
22
+ typically because they are irrelevant or dangerous
23
+ in an async context handled by the wrapper.
24
+ """
25
+
26
+ def __init__(self, _webdriver: "BrowserWebDriver"):
27
+ """
28
+ Initializes the TrioBrowserWebDriverWrapper.
29
+
30
+ Args:
31
+ _webdriver (BrowserWebDriver): The BrowserWebDriver instance to wrap.
32
+ """
33
+
34
+ self._webdriver = _webdriver
35
+
36
+ self._excluding_functions = ["to_wrapper", "execute_async_js_script"]
37
+
38
+ def __getattr__(self, name) -> Any:
39
+ """
40
+ Intercepts attribute access to wrap callable methods for asynchronous execution.
41
+
42
+ When an attribute (method or property) is accessed on this wrapper:
43
+ 1. Checks if the attribute name is in the `_excluding_functions` list. If so, raises AttributeError.
44
+ 2. Retrieves the attribute from the underlying `_webdriver` object.
45
+ 3. If the attribute is callable (i.e., a method), it returns a new asynchronous
46
+ function (`wrapped`). When this `wrapped` function is called (`await wrapper.some_method()`),
47
+ it executes the original synchronous method (`attr`) in a separate thread managed by Trio,
48
+ using `trio.to_thread.run_sync` and applying the capacity limiter from the wrapped object.
49
+ 4. If the attribute is not callable (e.g., a property), it returns the attribute's value directly.
50
+
51
+ Args:
52
+ name (str): The name of the attribute being accessed.
53
+
54
+ Returns:
55
+ Any: Either an asynchronous wrapper function (awaitable) for a method, or the direct value
56
+ of a property or non-callable attribute from the underlying `_webdriver` instance.
57
+
58
+ Raises:
59
+ AttributeError: If the attribute `name` is listed in `_excluding_functions` or
60
+ if it does not exist on the underlying `_webdriver` object.
61
+ """
62
+
63
+ if name in self._excluding_functions:
64
+ raise AttributeError(f"Don't use {name} method in TrioBrowserWebDriverWrapper!")
65
+ else:
66
+ attr = getattr(self._webdriver, name)
67
+
68
+ if callable(attr):
69
+ return trio_async_wrap(attr, self._webdriver.trio_capacity_limiter)
70
+
71
+ return attr