osn-selenium 1.0.0__py3-none-any.whl → 1.1.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.
- osn_selenium/_base_models.py +41 -0
- osn_selenium/_cdp_import.py +253 -0
- osn_selenium/abstract/executors/cdp.py +63 -0
- osn_selenium/browsers_handler/models.py +1 -1
- osn_selenium/dev_tools/_decorators.py +19 -10
- osn_selenium/dev_tools/_typehints.py +5 -2
- osn_selenium/dev_tools/_wrappers.py +0 -3
- osn_selenium/dev_tools/domains/__init__.py +2 -2
- osn_selenium/dev_tools/domains/abstract.py +1 -1
- osn_selenium/dev_tools/domains/fetch.py +1 -1
- osn_selenium/dev_tools/domains_default/fetch.py +1 -1
- osn_selenium/dev_tools/filters.py +1 -1
- osn_selenium/dev_tools/logger/main.py +0 -12
- osn_selenium/dev_tools/logger/models.py +1 -1
- osn_selenium/dev_tools/logger/target.py +42 -22
- osn_selenium/dev_tools/manager/base.py +0 -23
- osn_selenium/dev_tools/manager/lifecycle.py +1 -1
- osn_selenium/dev_tools/models.py +1 -1
- osn_selenium/dev_tools/settings.py +5 -1
- osn_selenium/dev_tools/target/base.py +12 -23
- osn_selenium/dev_tools/target/lifecycle.py +6 -1
- osn_selenium/dev_tools/target/logging.py +10 -2
- osn_selenium/exceptions/dependencies.py +60 -0
- osn_selenium/executors/sync/cdp.py +100 -0
- osn_selenium/executors/trio_threads/cdp.py +104 -0
- osn_selenium/executors/trio_threads/javascript.py +1 -1
- osn_selenium/executors/unified/javascript.py +0 -4
- osn_selenium/flags/base.py +1 -9
- osn_selenium/flags/blink.py +0 -6
- osn_selenium/flags/models/base.py +4 -4
- osn_selenium/flags/models/blink.py +1 -1
- osn_selenium/flags/models/values.py +1 -1
- osn_selenium/instances/sync/action_chains/__init__.py +6 -0
- osn_selenium/instances/sync/shadow_root.py +30 -8
- osn_selenium/instances/trio_threads/action_chains/__init__.py +6 -0
- osn_selenium/instances/trio_threads/action_chains/base.py +1 -1
- osn_selenium/instances/trio_threads/alert.py +1 -1
- osn_selenium/instances/trio_threads/browser.py +1 -1
- osn_selenium/instances/trio_threads/browsing_context.py +1 -1
- osn_selenium/instances/trio_threads/dialog.py +1 -1
- osn_selenium/instances/trio_threads/fedcm.py +1 -1
- osn_selenium/instances/trio_threads/mobile.py +1 -1
- osn_selenium/instances/trio_threads/network.py +1 -1
- osn_selenium/instances/trio_threads/permissions.py +1 -1
- osn_selenium/instances/trio_threads/script.py +1 -1
- osn_selenium/instances/trio_threads/shadow_root.py +46 -15
- osn_selenium/instances/trio_threads/storage.py +1 -1
- osn_selenium/instances/trio_threads/switch_to.py +1 -1
- osn_selenium/instances/trio_threads/web_driver_wait.py +1 -1
- osn_selenium/instances/trio_threads/web_element.py +1 -1
- osn_selenium/instances/trio_threads/web_extension.py +1 -1
- osn_selenium/javascript/fingerprint/__init__.py +1 -1
- osn_selenium/javascript/fingerprint/registry/models.py +1 -1
- osn_selenium/javascript/fingerprint/spoof/core_rules.py +1 -1
- osn_selenium/javascript/fingerprint/spoof/noise.py +1 -1
- osn_selenium/javascript/models.py +1 -1
- osn_selenium/models.py +2 -47
- osn_selenium/trio_threads_mixin.py +159 -0
- osn_selenium/webdrivers/_args_helpers.py +2 -2
- osn_selenium/webdrivers/_bridges.py +2 -2
- osn_selenium/webdrivers/_executable_tables/models.py +1 -1
- osn_selenium/webdrivers/sync/blink/__init__.py +11 -1
- osn_selenium/webdrivers/sync/blink/base.py +13 -1
- osn_selenium/webdrivers/sync/chrome/__init__.py +36 -1
- osn_selenium/webdrivers/sync/chrome/base.py +13 -1
- osn_selenium/webdrivers/sync/core/__init__.py +10 -1
- osn_selenium/webdrivers/sync/core/base.py +16 -8
- osn_selenium/webdrivers/sync/edge/__init__.py +36 -1
- osn_selenium/webdrivers/sync/edge/base.py +13 -1
- osn_selenium/webdrivers/sync/yandex/__init__.py +36 -1
- osn_selenium/webdrivers/sync/yandex/base.py +13 -1
- osn_selenium/webdrivers/trio_threads/blink/__init__.py +11 -1
- osn_selenium/webdrivers/trio_threads/blink/base.py +11 -1
- osn_selenium/webdrivers/trio_threads/blink/casting.py +1 -1
- osn_selenium/webdrivers/trio_threads/blink/features.py +1 -1
- osn_selenium/webdrivers/trio_threads/blink/logging.py +1 -1
- osn_selenium/webdrivers/trio_threads/blink/network.py +1 -1
- osn_selenium/webdrivers/trio_threads/chrome/__init__.py +34 -1
- osn_selenium/webdrivers/trio_threads/chrome/base.py +14 -2
- osn_selenium/webdrivers/trio_threads/core/__init__.py +10 -4
- osn_selenium/webdrivers/trio_threads/core/actions.py +1 -1
- osn_selenium/webdrivers/trio_threads/core/auth.py +1 -1
- osn_selenium/webdrivers/trio_threads/core/base.py +15 -7
- osn_selenium/webdrivers/trio_threads/core/capture.py +1 -1
- osn_selenium/webdrivers/trio_threads/core/comonents.py +1 -1
- osn_selenium/webdrivers/trio_threads/core/devtools.py +1 -1
- osn_selenium/webdrivers/trio_threads/core/element.py +1 -1
- osn_selenium/webdrivers/trio_threads/core/file.py +2 -2
- osn_selenium/webdrivers/trio_threads/core/lifecycle.py +1 -1
- osn_selenium/webdrivers/trio_threads/core/navigation.py +1 -1
- osn_selenium/webdrivers/trio_threads/core/script.py +1 -1
- osn_selenium/webdrivers/trio_threads/core/settings.py +1 -1
- osn_selenium/webdrivers/trio_threads/core/storage.py +1 -1
- osn_selenium/webdrivers/trio_threads/core/timeouts.py +1 -1
- osn_selenium/webdrivers/trio_threads/core/window.py +3 -3
- osn_selenium/webdrivers/trio_threads/edge/__init__.py +34 -1
- osn_selenium/webdrivers/trio_threads/edge/base.py +14 -2
- osn_selenium/webdrivers/trio_threads/yandex/__init__.py +34 -1
- osn_selenium/webdrivers/trio_threads/yandex/base.py +14 -2
- osn_selenium/webdrivers/unified/blink/base.py +5 -1
- osn_selenium/webdrivers/unified/chrome/base.py +5 -1
- osn_selenium/webdrivers/unified/core/base.py +9 -2
- osn_selenium/webdrivers/unified/edge/base.py +5 -1
- osn_selenium/webdrivers/unified/yandex/base.py +5 -1
- {osn_selenium-1.0.0.dist-info → osn_selenium-1.1.0.dist-info}/METADATA +22 -9
- {osn_selenium-1.0.0.dist-info → osn_selenium-1.1.0.dist-info}/RECORD +108 -101
- {osn_selenium-1.0.0.dist-info → osn_selenium-1.1.0.dist-info}/WHEEL +1 -1
- {osn_selenium-1.0.0.dist-info → osn_selenium-1.1.0.dist-info}/top_level.txt +0 -0
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import trio
|
|
2
2
|
from osn_selenium.models import WindowRect
|
|
3
|
-
from osn_selenium.
|
|
3
|
+
from osn_selenium.trio_threads_mixin import TrioThreadMixin
|
|
4
|
+
from osn_selenium.flags.base import BrowserFlagsManager
|
|
5
|
+
from osn_selenium.flags.models.base import BrowserFlags
|
|
6
|
+
from selenium.webdriver.common.bidi.session import Session
|
|
4
7
|
from typing import (
|
|
5
8
|
Any,
|
|
6
9
|
Dict,
|
|
10
|
+
Mapping,
|
|
7
11
|
Optional,
|
|
8
12
|
Type
|
|
9
13
|
)
|
|
10
|
-
from osn_selenium.flags.base import BrowserFlagsManager
|
|
11
|
-
from osn_selenium.flags.models.base import BrowserFlags
|
|
12
|
-
from selenium.webdriver.common.bidi.session import Session
|
|
13
|
-
from osn_selenium._typehints import (
|
|
14
|
-
ARCHITECTURES_TYPEHINT
|
|
15
|
-
)
|
|
16
14
|
from selenium.webdriver.remote.errorhandler import ErrorHandler
|
|
17
15
|
from osn_selenium.executors.trio_threads.cdp import CDPExecutor
|
|
18
16
|
from osn_selenium.executors.trio_threads.javascript import JSExecutor
|
|
19
17
|
from selenium.webdriver.remote.locator_converter import LocatorConverter
|
|
20
18
|
from selenium.webdriver.remote.remote_connection import RemoteConnection
|
|
21
19
|
from osn_selenium.webdrivers.unified.core.base import UnifiedCoreBaseMixin
|
|
20
|
+
from osn_selenium._typehints import (
|
|
21
|
+
ARCHITECTURES_TYPEHINT,
|
|
22
|
+
PATH_TYPEHINT
|
|
23
|
+
)
|
|
22
24
|
from osn_selenium.abstract.webdriver.core.base import (
|
|
23
25
|
AbstractCoreBaseMixin
|
|
24
26
|
)
|
|
@@ -51,6 +53,8 @@ class CoreBaseMixin(UnifiedCoreBaseMixin, TrioThreadMixin, AbstractCoreBaseMixin
|
|
|
51
53
|
script_timeout: int = 5,
|
|
52
54
|
window_rect: Optional[WindowRect] = None,
|
|
53
55
|
capacity_limiter: Optional[trio.CapacityLimiter] = None,
|
|
56
|
+
cdp_versioned_packages_paths: Optional[Mapping[int, PATH_TYPEHINT]] = None,
|
|
57
|
+
ignore_cdp_version_package_missing: bool = True,
|
|
54
58
|
) -> None:
|
|
55
59
|
"""
|
|
56
60
|
Initializes the base mixin for Trio-based WebDrivers.
|
|
@@ -74,6 +78,8 @@ class CoreBaseMixin(UnifiedCoreBaseMixin, TrioThreadMixin, AbstractCoreBaseMixin
|
|
|
74
78
|
browser window. Defaults to None.
|
|
75
79
|
capacity_limiter (Optional[trio.CapacityLimiter]): A Trio capacity limiter used to
|
|
76
80
|
throttle concurrent thread-based operations. Defaults to None.
|
|
81
|
+
cdp_versioned_packages_paths (Optional[Mapping[int, PATH_TYPEHINT]]): Custom local paths for specific CDP versions packages.
|
|
82
|
+
ignore_cdp_version_package_missing (bool): Whether to ignore missing CDP package errors.
|
|
77
83
|
"""
|
|
78
84
|
|
|
79
85
|
UnifiedCoreBaseMixin.__init__(
|
|
@@ -86,6 +92,8 @@ class CoreBaseMixin(UnifiedCoreBaseMixin, TrioThreadMixin, AbstractCoreBaseMixin
|
|
|
86
92
|
page_load_timeout=page_load_timeout,
|
|
87
93
|
script_timeout=script_timeout,
|
|
88
94
|
window_rect=window_rect,
|
|
95
|
+
cdp_versioned_packages_paths=cdp_versioned_packages_paths,
|
|
96
|
+
ignore_cdp_version_package_missing=ignore_cdp_version_package_missing,
|
|
89
97
|
)
|
|
90
98
|
|
|
91
99
|
TrioThreadMixin.__init__(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from osn_selenium.
|
|
1
|
+
from osn_selenium.trio_threads_mixin import TrioThreadMixin
|
|
2
2
|
from osn_selenium.instances.trio_threads.dialog import Dialog
|
|
3
3
|
from osn_selenium.instances.trio_threads.mobile import Mobile
|
|
4
4
|
from osn_selenium.instances.trio_threads.browser import Browser
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from typing import List, Optional
|
|
2
2
|
from selenium.webdriver.common.by import By
|
|
3
|
-
from osn_selenium.
|
|
3
|
+
from osn_selenium.trio_threads_mixin import TrioThreadMixin
|
|
4
4
|
from osn_selenium.instances.trio_threads.web_element import WebElement
|
|
5
5
|
from osn_selenium.instances.convert import (
|
|
6
6
|
get_trio_thread_instance_wrapper
|
|
@@ -4,7 +4,7 @@ from typing import (
|
|
|
4
4
|
AsyncGenerator,
|
|
5
5
|
List
|
|
6
6
|
)
|
|
7
|
-
from osn_selenium.
|
|
7
|
+
from osn_selenium.trio_threads_mixin import TrioThreadMixin
|
|
8
8
|
from osn_selenium.webdrivers.unified.core.file import UnifiedCoreFileMixin
|
|
9
9
|
from osn_selenium.abstract.webdriver.core.file import (
|
|
10
10
|
AbstractCoreFileMixin
|
|
@@ -38,7 +38,7 @@ class CoreFileMixin(UnifiedCoreFileMixin, TrioThreadMixin, AbstractCoreFileMixin
|
|
|
38
38
|
|
|
39
39
|
@asynccontextmanager
|
|
40
40
|
async def file_detector_context(self, file_detector_class: Any, *args: Any, **kwargs: Any) -> AsyncGenerator[Any, Any]:
|
|
41
|
-
async with self.sync_to_trio_context(context_manager_factory=self.
|
|
41
|
+
async with self.sync_to_trio_context(context_manager_factory=self._file_detector_context_impl)(file_detector_class, *args, **kwargs) as file_detector:
|
|
42
42
|
yield file_detector
|
|
43
43
|
|
|
44
44
|
async def get_downloadable_files(self) -> List[str]:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from typing import Any, List, Optional
|
|
2
|
-
from osn_selenium.
|
|
2
|
+
from osn_selenium.trio_threads_mixin import TrioThreadMixin
|
|
3
3
|
from osn_selenium.instances.trio_threads.script import Script
|
|
4
4
|
from osn_selenium.instances.convert import (
|
|
5
5
|
get_trio_thread_instance_wrapper
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from typing import Optional
|
|
2
2
|
from osn_selenium.models import WindowRect
|
|
3
|
-
from osn_selenium.
|
|
3
|
+
from osn_selenium.trio_threads_mixin import TrioThreadMixin
|
|
4
4
|
from osn_selenium.flags.models.base import BrowserFlags
|
|
5
5
|
from osn_selenium.webdrivers.unified.core.settings import (
|
|
6
6
|
UnifiedCoreSettingsMixin
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from typing import Optional
|
|
2
|
-
from osn_selenium.
|
|
2
|
+
from osn_selenium.trio_threads_mixin import TrioThreadMixin
|
|
3
3
|
from selenium.webdriver.common.timeouts import Timeouts
|
|
4
4
|
from osn_selenium.webdrivers.unified.core.timeouts import (
|
|
5
5
|
UnifiedCoreTimeoutsMixin
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from osn_selenium.
|
|
1
|
+
from osn_selenium.trio_threads_mixin import TrioThreadMixin
|
|
2
2
|
from typing import (
|
|
3
3
|
List,
|
|
4
4
|
Literal,
|
|
@@ -92,8 +92,8 @@ class CoreWindowMixin(UnifiedCoreWindowMixin, TrioThreadMixin, AbstractCoreWindo
|
|
|
92
92
|
async def set_window_size(self, width: int, height: int, windowHandle: str = "current") -> None:
|
|
93
93
|
await self.sync_to_trio(sync_function=self._set_window_size_impl)(width=width, height=height, windowHandle=windowHandle)
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
legacy =
|
|
95
|
+
def switch_to(self) -> SwitchTo:
|
|
96
|
+
legacy = self._switch_to_impl()
|
|
97
97
|
return get_trio_thread_instance_wrapper(
|
|
98
98
|
wrapper_class=SwitchTo,
|
|
99
99
|
legacy_object=legacy,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import trio
|
|
2
|
-
from typing import Optional, Type
|
|
3
2
|
from osn_selenium.models import WindowRect
|
|
3
|
+
from typing import (
|
|
4
|
+
Mapping,
|
|
5
|
+
Optional,
|
|
6
|
+
Type
|
|
7
|
+
)
|
|
4
8
|
from osn_selenium._typehints import PATH_TYPEHINT
|
|
5
9
|
from osn_selenium.flags.edge import EdgeFlagsManager
|
|
6
10
|
from osn_selenium.flags.models.edge import EdgeFlags
|
|
@@ -46,7 +50,32 @@ class EdgeWebDriver(
|
|
|
46
50
|
window_rect: Optional[WindowRect] = None,
|
|
47
51
|
devtools_settings: Optional[DevToolsSettings] = None,
|
|
48
52
|
capacity_limiter: Optional[trio.CapacityLimiter] = None,
|
|
53
|
+
cdp_versioned_packages_paths: Optional[Mapping[int, PATH_TYPEHINT]] = None,
|
|
54
|
+
ignore_cdp_version_package_missing: bool = True,
|
|
49
55
|
):
|
|
56
|
+
"""
|
|
57
|
+
Initializes the Trio-based Edge WebDriver with specified configuration.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
webdriver_path (str): Path to the EdgeDriver executable.
|
|
61
|
+
flags_manager_type (Type[EdgeFlagsManager]): The class type used for managing Edge flags.
|
|
62
|
+
Defaults to EdgeFlagsManager.
|
|
63
|
+
use_browser_exe (bool): Whether to use a specific browser executable path or auto-detect.
|
|
64
|
+
Defaults to True.
|
|
65
|
+
browser_name_in_system (str): The name of the browser in the system registry or path.
|
|
66
|
+
Defaults to "Microsoft Edge".
|
|
67
|
+
browser_exe (Optional[PATH_TYPEHINT]): Explicit path to the Edge browser executable.
|
|
68
|
+
flags (Optional[EdgeFlags]): Initial set of flags.
|
|
69
|
+
start_page_url (str): The initial URL. Defaults to "about:blank".
|
|
70
|
+
implicitly_wait (int): Default implicit wait time.
|
|
71
|
+
page_load_timeout (int): Default page load timeout.
|
|
72
|
+
script_timeout (int): Default script timeout.
|
|
73
|
+
window_rect (Optional[WindowRect]): Initial window dimensions.
|
|
74
|
+
capacity_limiter (Optional[trio.CapacityLimiter]): Trio capacity limiter.
|
|
75
|
+
cdp_versioned_packages_paths (Optional[Mapping[int, PATH_TYPEHINT]]): Custom local paths for specific CDP versions packages.
|
|
76
|
+
ignore_cdp_version_package_missing (bool): Whether to ignore missing CDP package errors.
|
|
77
|
+
"""
|
|
78
|
+
|
|
50
79
|
BlinkWebDriver.__init__(
|
|
51
80
|
self,
|
|
52
81
|
browser_exe=browser_exe,
|
|
@@ -61,6 +90,8 @@ class EdgeWebDriver(
|
|
|
61
90
|
window_rect=window_rect,
|
|
62
91
|
devtools_settings=devtools_settings,
|
|
63
92
|
capacity_limiter=capacity_limiter,
|
|
93
|
+
cdp_versioned_packages_paths=cdp_versioned_packages_paths,
|
|
94
|
+
ignore_cdp_version_package_missing=ignore_cdp_version_package_missing,
|
|
64
95
|
)
|
|
65
96
|
|
|
66
97
|
EdgeBaseMixin.__init__(
|
|
@@ -78,4 +109,6 @@ class EdgeWebDriver(
|
|
|
78
109
|
script_timeout=script_timeout,
|
|
79
110
|
window_rect=window_rect,
|
|
80
111
|
capacity_limiter=capacity_limiter,
|
|
112
|
+
cdp_versioned_packages_paths=cdp_versioned_packages_paths,
|
|
113
|
+
ignore_cdp_version_package_missing=ignore_cdp_version_package_missing,
|
|
81
114
|
)
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import trio
|
|
2
|
-
from typing import Optional, Type
|
|
3
2
|
from osn_selenium.models import WindowRect
|
|
3
|
+
from typing import (
|
|
4
|
+
Mapping,
|
|
5
|
+
Optional,
|
|
6
|
+
Type
|
|
7
|
+
)
|
|
4
8
|
from selenium.webdriver import Edge as legacyEdge
|
|
5
9
|
from osn_selenium.flags.edge import EdgeFlagsManager
|
|
6
10
|
from osn_selenium.flags.models.edge import EdgeFlags
|
|
@@ -42,9 +46,11 @@ class EdgeBaseMixin(UnifiedEdgeBaseMixin, BlinkBaseMixin, AbstractEdgeBaseMixin)
|
|
|
42
46
|
script_timeout: int = 5,
|
|
43
47
|
window_rect: Optional[WindowRect] = None,
|
|
44
48
|
capacity_limiter: Optional[trio.CapacityLimiter] = None,
|
|
49
|
+
cdp_versioned_packages_paths: Optional[Mapping[int, PATH_TYPEHINT]] = None,
|
|
50
|
+
ignore_cdp_version_package_missing: bool = True,
|
|
45
51
|
):
|
|
46
52
|
"""
|
|
47
|
-
Initializes the Trio-based Edge WebDriver mixin.
|
|
53
|
+
Initializes the Trio-based Edge WebDriver mixin with specified configuration.
|
|
48
54
|
|
|
49
55
|
Args:
|
|
50
56
|
webdriver_path (str): Path to the EdgeDriver executable.
|
|
@@ -63,6 +69,8 @@ class EdgeBaseMixin(UnifiedEdgeBaseMixin, BlinkBaseMixin, AbstractEdgeBaseMixin)
|
|
|
63
69
|
script_timeout (int): Default script timeout.
|
|
64
70
|
window_rect (Optional[WindowRect]): Initial window dimensions.
|
|
65
71
|
capacity_limiter (Optional[trio.CapacityLimiter]): Trio capacity limiter.
|
|
72
|
+
cdp_versioned_packages_paths (Optional[Mapping[int, PATH_TYPEHINT]]): Custom local paths for specific CDP versions packages.
|
|
73
|
+
ignore_cdp_version_package_missing (bool): Whether to ignore missing CDP package errors.
|
|
66
74
|
"""
|
|
67
75
|
|
|
68
76
|
BlinkBaseMixin.__init__(
|
|
@@ -80,6 +88,8 @@ class EdgeBaseMixin(UnifiedEdgeBaseMixin, BlinkBaseMixin, AbstractEdgeBaseMixin)
|
|
|
80
88
|
script_timeout=script_timeout,
|
|
81
89
|
window_rect=window_rect,
|
|
82
90
|
capacity_limiter=capacity_limiter,
|
|
91
|
+
cdp_versioned_packages_paths=cdp_versioned_packages_paths,
|
|
92
|
+
ignore_cdp_version_package_missing=ignore_cdp_version_package_missing,
|
|
83
93
|
)
|
|
84
94
|
|
|
85
95
|
UnifiedEdgeBaseMixin.__init__(
|
|
@@ -96,6 +106,8 @@ class EdgeBaseMixin(UnifiedEdgeBaseMixin, BlinkBaseMixin, AbstractEdgeBaseMixin)
|
|
|
96
106
|
page_load_timeout=page_load_timeout,
|
|
97
107
|
script_timeout=script_timeout,
|
|
98
108
|
window_rect=window_rect,
|
|
109
|
+
cdp_versioned_packages_paths=cdp_versioned_packages_paths,
|
|
110
|
+
ignore_cdp_version_package_missing=ignore_cdp_version_package_missing,
|
|
99
111
|
)
|
|
100
112
|
|
|
101
113
|
@property
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import trio
|
|
2
|
-
from typing import Optional, Type
|
|
3
2
|
from osn_selenium.models import WindowRect
|
|
3
|
+
from typing import (
|
|
4
|
+
Mapping,
|
|
5
|
+
Optional,
|
|
6
|
+
Type
|
|
7
|
+
)
|
|
4
8
|
from osn_selenium._typehints import PATH_TYPEHINT
|
|
5
9
|
from osn_selenium.flags.models.yandex import YandexFlags
|
|
6
10
|
from osn_selenium.flags.yandex import YandexFlagsManager
|
|
@@ -46,7 +50,32 @@ class YandexWebDriver(
|
|
|
46
50
|
window_rect: Optional[WindowRect] = None,
|
|
47
51
|
devtools_settings: Optional[DevToolsSettings] = None,
|
|
48
52
|
capacity_limiter: Optional[trio.CapacityLimiter] = None,
|
|
53
|
+
cdp_versioned_packages_paths: Optional[Mapping[int, PATH_TYPEHINT]] = None,
|
|
54
|
+
ignore_cdp_version_package_missing: bool = True,
|
|
49
55
|
):
|
|
56
|
+
"""
|
|
57
|
+
Initializes the Trio-based Yandex WebDriver with specified configuration.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
webdriver_path (str): Path to the YandexDriver executable.
|
|
61
|
+
flags_manager_type (Type[YandexFlagsManager]): The class type used for managing Yandex flags.
|
|
62
|
+
Defaults to YandexFlagsManager.
|
|
63
|
+
use_browser_exe (bool): Whether to use a specific browser executable path or auto-detect.
|
|
64
|
+
Defaults to True.
|
|
65
|
+
browser_name_in_system (str): The name of the browser in the system registry or path.
|
|
66
|
+
Defaults to "Yandex".
|
|
67
|
+
browser_exe (Optional[PATH_TYPEHINT]): Explicit path to the Yandex browser executable.
|
|
68
|
+
flags (Optional[YandexFlags]): Initial set of flags.
|
|
69
|
+
start_page_url (str): The initial URL. Defaults to "about:blank".
|
|
70
|
+
implicitly_wait (int): Default implicit wait time.
|
|
71
|
+
page_load_timeout (int): Default page load timeout.
|
|
72
|
+
script_timeout (int): Default script timeout.
|
|
73
|
+
window_rect (Optional[WindowRect]): Initial window dimensions.
|
|
74
|
+
capacity_limiter (Optional[trio.CapacityLimiter]): Trio capacity limiter.
|
|
75
|
+
cdp_versioned_packages_paths (Optional[Mapping[int, PATH_TYPEHINT]]): Custom local paths for specific CDP versions packages.
|
|
76
|
+
ignore_cdp_version_package_missing (bool): Whether to ignore missing CDP package errors.
|
|
77
|
+
"""
|
|
78
|
+
|
|
50
79
|
ChromeWebDriver.__init__(
|
|
51
80
|
self,
|
|
52
81
|
browser_exe=browser_exe,
|
|
@@ -61,6 +90,8 @@ class YandexWebDriver(
|
|
|
61
90
|
window_rect=window_rect,
|
|
62
91
|
devtools_settings=devtools_settings,
|
|
63
92
|
capacity_limiter=capacity_limiter,
|
|
93
|
+
cdp_versioned_packages_paths=cdp_versioned_packages_paths,
|
|
94
|
+
ignore_cdp_version_package_missing=ignore_cdp_version_package_missing,
|
|
64
95
|
)
|
|
65
96
|
|
|
66
97
|
YandexBaseMixin.__init__(
|
|
@@ -78,4 +109,6 @@ class YandexWebDriver(
|
|
|
78
109
|
script_timeout=script_timeout,
|
|
79
110
|
window_rect=window_rect,
|
|
80
111
|
capacity_limiter=capacity_limiter,
|
|
112
|
+
cdp_versioned_packages_paths=cdp_versioned_packages_paths,
|
|
113
|
+
ignore_cdp_version_package_missing=ignore_cdp_version_package_missing,
|
|
81
114
|
)
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import trio
|
|
2
|
-
from typing import Optional, Type
|
|
3
2
|
from osn_selenium.models import WindowRect
|
|
3
|
+
from typing import (
|
|
4
|
+
Mapping,
|
|
5
|
+
Optional,
|
|
6
|
+
Type
|
|
7
|
+
)
|
|
4
8
|
from osn_selenium.flags.models.yandex import YandexFlags
|
|
5
9
|
from osn_selenium.flags.yandex import YandexFlagsManager
|
|
6
10
|
from osn_selenium.webdrivers.trio_threads.chrome.base import ChromeBaseMixin
|
|
@@ -43,9 +47,11 @@ class YandexBaseMixin(UnifiedYandexBaseMixin, ChromeBaseMixin, AbstractYandexBas
|
|
|
43
47
|
script_timeout: int = 5,
|
|
44
48
|
window_rect: Optional[WindowRect] = None,
|
|
45
49
|
capacity_limiter: Optional[trio.CapacityLimiter] = None,
|
|
50
|
+
cdp_versioned_packages_paths: Optional[Mapping[int, PATH_TYPEHINT]] = None,
|
|
51
|
+
ignore_cdp_version_package_missing: bool = True,
|
|
46
52
|
):
|
|
47
53
|
"""
|
|
48
|
-
Initializes the Trio-based Yandex WebDriver mixin.
|
|
54
|
+
Initializes the Trio-based Yandex WebDriver mixin with specified configuration.
|
|
49
55
|
|
|
50
56
|
Args:
|
|
51
57
|
webdriver_path (str): Path to the YandexDriver executable.
|
|
@@ -64,6 +70,8 @@ class YandexBaseMixin(UnifiedYandexBaseMixin, ChromeBaseMixin, AbstractYandexBas
|
|
|
64
70
|
script_timeout (int): Default script timeout.
|
|
65
71
|
window_rect (Optional[WindowRect]): Initial window dimensions.
|
|
66
72
|
capacity_limiter (Optional[trio.CapacityLimiter]): Trio capacity limiter.
|
|
73
|
+
cdp_versioned_packages_paths (Optional[Mapping[int, PATH_TYPEHINT]]): Custom local paths for specific CDP versions packages.
|
|
74
|
+
ignore_cdp_version_package_missing (bool): Whether to ignore missing CDP package errors.
|
|
67
75
|
"""
|
|
68
76
|
|
|
69
77
|
ChromeBaseMixin.__init__(
|
|
@@ -81,6 +89,8 @@ class YandexBaseMixin(UnifiedYandexBaseMixin, ChromeBaseMixin, AbstractYandexBas
|
|
|
81
89
|
script_timeout=script_timeout,
|
|
82
90
|
window_rect=window_rect,
|
|
83
91
|
capacity_limiter=capacity_limiter,
|
|
92
|
+
cdp_versioned_packages_paths=cdp_versioned_packages_paths,
|
|
93
|
+
ignore_cdp_version_package_missing=ignore_cdp_version_package_missing,
|
|
84
94
|
)
|
|
85
95
|
|
|
86
96
|
UnifiedYandexBaseMixin.__init__(
|
|
@@ -97,4 +107,6 @@ class YandexBaseMixin(UnifiedYandexBaseMixin, ChromeBaseMixin, AbstractYandexBas
|
|
|
97
107
|
page_load_timeout=page_load_timeout,
|
|
98
108
|
script_timeout=script_timeout,
|
|
99
109
|
window_rect=window_rect,
|
|
110
|
+
cdp_versioned_packages_paths=cdp_versioned_packages_paths,
|
|
111
|
+
ignore_cdp_version_package_missing=ignore_cdp_version_package_missing,
|
|
100
112
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pathlib
|
|
2
|
-
from typing import Optional, Type
|
|
2
|
+
from typing import Mapping, Optional, Type
|
|
3
3
|
from osn_selenium.models import WindowRect
|
|
4
4
|
from osn_selenium.flags.blink import BlinkFlagsManager
|
|
5
5
|
from osn_selenium.flags.models.values import ArgumentValue
|
|
@@ -44,6 +44,8 @@ class UnifiedBlinkBaseMixin(UnifiedCoreBaseMixin):
|
|
|
44
44
|
page_load_timeout: int = 5,
|
|
45
45
|
script_timeout: int = 5,
|
|
46
46
|
window_rect: Optional[WindowRect] = None,
|
|
47
|
+
cdp_versioned_packages_paths: Optional[Mapping[int, PATH_TYPEHINT]] = None,
|
|
48
|
+
ignore_cdp_version_package_missing: bool = True,
|
|
47
49
|
):
|
|
48
50
|
UnifiedCoreBaseMixin.__init__(
|
|
49
51
|
self,
|
|
@@ -55,6 +57,8 @@ class UnifiedBlinkBaseMixin(UnifiedCoreBaseMixin):
|
|
|
55
57
|
page_load_timeout=page_load_timeout,
|
|
56
58
|
script_timeout=script_timeout,
|
|
57
59
|
window_rect=window_rect,
|
|
60
|
+
cdp_versioned_packages_paths=cdp_versioned_packages_paths,
|
|
61
|
+
ignore_cdp_version_package_missing=ignore_cdp_version_package_missing,
|
|
58
62
|
)
|
|
59
63
|
|
|
60
64
|
if browser_exe is not None:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Optional, Type
|
|
1
|
+
from typing import Mapping, Optional, Type
|
|
2
2
|
from osn_selenium.models import WindowRect
|
|
3
3
|
from osn_selenium.flags.chrome import ChromeFlagsManager
|
|
4
4
|
from osn_selenium.flags.models.chrome import ChromeFlags
|
|
@@ -32,6 +32,8 @@ class UnifiedChromeBaseMixin(UnifiedBlinkBaseMixin):
|
|
|
32
32
|
page_load_timeout: int = 5,
|
|
33
33
|
script_timeout: int = 5,
|
|
34
34
|
window_rect: Optional[WindowRect] = None,
|
|
35
|
+
cdp_versioned_packages_paths: Optional[Mapping[int, PATH_TYPEHINT]] = None,
|
|
36
|
+
ignore_cdp_version_package_missing: bool = True,
|
|
35
37
|
):
|
|
36
38
|
UnifiedBlinkBaseMixin.__init__(
|
|
37
39
|
self,
|
|
@@ -47,6 +49,8 @@ class UnifiedChromeBaseMixin(UnifiedBlinkBaseMixin):
|
|
|
47
49
|
page_load_timeout=page_load_timeout,
|
|
48
50
|
script_timeout=script_timeout,
|
|
49
51
|
window_rect=window_rect,
|
|
52
|
+
cdp_versioned_packages_paths=cdp_versioned_packages_paths,
|
|
53
|
+
ignore_cdp_version_package_missing=ignore_cdp_version_package_missing,
|
|
50
54
|
)
|
|
51
55
|
|
|
52
56
|
@property
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
from osn_selenium._cdp_import import install_cdp_hook
|
|
1
2
|
from osn_selenium.models import WindowRect
|
|
2
3
|
from typing import (
|
|
3
4
|
Any,
|
|
4
5
|
Dict,
|
|
5
|
-
Optional,
|
|
6
|
+
Mapping, Optional,
|
|
6
7
|
Type
|
|
7
8
|
)
|
|
8
9
|
from osn_selenium.flags.base import BrowserFlagsManager
|
|
9
10
|
from osn_selenium.flags.models.base import BrowserFlags
|
|
10
11
|
from selenium.webdriver.common.bidi.session import Session
|
|
11
12
|
from osn_selenium._typehints import (
|
|
12
|
-
ARCHITECTURES_TYPEHINT
|
|
13
|
+
ARCHITECTURES_TYPEHINT, PATH_TYPEHINT
|
|
13
14
|
)
|
|
14
15
|
from selenium.webdriver.remote.errorhandler import ErrorHandler
|
|
15
16
|
from osn_selenium.webdrivers._decorators import requires_driver
|
|
@@ -37,6 +38,8 @@ class UnifiedCoreBaseMixin:
|
|
|
37
38
|
page_load_timeout: int = 5,
|
|
38
39
|
script_timeout: int = 5,
|
|
39
40
|
window_rect: Optional[WindowRect] = None,
|
|
41
|
+
cdp_versioned_packages_paths: Optional[Mapping[int, PATH_TYPEHINT]] = None,
|
|
42
|
+
ignore_cdp_version_package_missing: bool = True,
|
|
40
43
|
) -> None:
|
|
41
44
|
self._window_rect = window_rect
|
|
42
45
|
self._webdriver_path = webdriver_path
|
|
@@ -50,6 +53,10 @@ class UnifiedCoreBaseMixin:
|
|
|
50
53
|
|
|
51
54
|
if flags is not None:
|
|
52
55
|
self._webdriver_flags_manager.update_flags(flags)
|
|
56
|
+
|
|
57
|
+
if not getattr(self, "cdp_hook_installed", False):
|
|
58
|
+
install_cdp_hook(cdp_paths=cdp_versioned_packages_paths, ignore_package_missing=ignore_cdp_version_package_missing)
|
|
59
|
+
setattr(self, "cdp_hook_installed", True)
|
|
53
60
|
|
|
54
61
|
@property
|
|
55
62
|
def _architecture_impl(self) -> ARCHITECTURES_TYPEHINT:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Optional, Type
|
|
1
|
+
from typing import Mapping, Optional, Type
|
|
2
2
|
from osn_selenium.models import WindowRect
|
|
3
3
|
from selenium.webdriver import Edge as legacyEdge
|
|
4
4
|
from osn_selenium.flags.models.edge import EdgeFlags
|
|
@@ -30,6 +30,8 @@ class UnifiedEdgeBaseMixin(UnifiedBlinkBaseMixin):
|
|
|
30
30
|
page_load_timeout: int = 5,
|
|
31
31
|
script_timeout: int = 5,
|
|
32
32
|
window_rect: Optional[WindowRect] = None,
|
|
33
|
+
cdp_versioned_packages_paths: Optional[Mapping[int, PATH_TYPEHINT]] = None,
|
|
34
|
+
ignore_cdp_version_package_missing: bool = True,
|
|
33
35
|
):
|
|
34
36
|
UnifiedBlinkBaseMixin.__init__(
|
|
35
37
|
self,
|
|
@@ -45,6 +47,8 @@ class UnifiedEdgeBaseMixin(UnifiedBlinkBaseMixin):
|
|
|
45
47
|
page_load_timeout=page_load_timeout,
|
|
46
48
|
script_timeout=script_timeout,
|
|
47
49
|
window_rect=window_rect,
|
|
50
|
+
cdp_versioned_packages_paths=cdp_versioned_packages_paths,
|
|
51
|
+
ignore_cdp_version_package_missing=ignore_cdp_version_package_missing,
|
|
48
52
|
)
|
|
49
53
|
|
|
50
54
|
@property
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Optional, Type
|
|
1
|
+
from typing import Mapping, Optional, Type
|
|
2
2
|
from osn_selenium.models import WindowRect
|
|
3
3
|
from osn_selenium.flags.models.yandex import YandexFlags
|
|
4
4
|
from osn_selenium.flags.yandex import YandexFlagsManager
|
|
@@ -32,6 +32,8 @@ class UnifiedYandexBaseMixin(UnifiedChromeBaseMixin):
|
|
|
32
32
|
page_load_timeout: int = 5,
|
|
33
33
|
script_timeout: int = 5,
|
|
34
34
|
window_rect: Optional[WindowRect] = None,
|
|
35
|
+
cdp_versioned_packages_paths: Optional[Mapping[int, PATH_TYPEHINT]] = None,
|
|
36
|
+
ignore_cdp_version_package_missing: bool = True,
|
|
35
37
|
):
|
|
36
38
|
UnifiedChromeBaseMixin.__init__(
|
|
37
39
|
self,
|
|
@@ -47,6 +49,8 @@ class UnifiedYandexBaseMixin(UnifiedChromeBaseMixin):
|
|
|
47
49
|
page_load_timeout=page_load_timeout,
|
|
48
50
|
script_timeout=script_timeout,
|
|
49
51
|
window_rect=window_rect,
|
|
52
|
+
cdp_versioned_packages_paths=cdp_versioned_packages_paths,
|
|
53
|
+
ignore_cdp_version_package_missing=ignore_cdp_version_package_missing,
|
|
50
54
|
)
|
|
51
55
|
|
|
52
56
|
@property
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: osn-selenium
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: An advanced, asynchronous wrapper for Selenium designed for fine-grained browser control. It leverages `trio` for async operations, provides human-like action chains for more natural automation, and offers deep integration with the Chrome DevTools Protocol (CDP) for advanced features like network interception. The library is structured to be extensible, with built-in support for Blink-based browsers like Chrome, Edge, and Yandex.
|
|
5
|
-
Author: oddshellnick
|
|
6
|
-
|
|
5
|
+
Author-email: oddshellnick <oddshellnick.programming@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/oddshellnick/osn-selenium
|
|
7
|
+
Project-URL: Issues, https://github.com/oddshellnick/osn-selenium/issues
|
|
8
|
+
Requires-Python: >=3.12
|
|
7
9
|
Description-Content-Type: text/markdown
|
|
8
10
|
Requires-Dist: trio<1.0.0,>=0.32.0
|
|
9
11
|
Requires-Dist: selenium<5.0.0,>=4.40.0
|
|
@@ -11,17 +13,13 @@ Requires-Dist: pydantic<3.0.0,>=2.0.0
|
|
|
11
13
|
Requires-Dist: trio-websocket<1.0.0,>=0.12.0
|
|
12
14
|
Requires-Dist: pywin32>=310; sys_platform == "win32"
|
|
13
15
|
Requires-Dist: osn-system-utils<0.1.0,>=0.0.4
|
|
14
|
-
Dynamic: author
|
|
15
|
-
Dynamic: author-email
|
|
16
|
-
Dynamic: description
|
|
17
|
-
Dynamic: description-content-type
|
|
18
|
-
Dynamic: requires-dist
|
|
19
|
-
Dynamic: summary
|
|
20
16
|
|
|
21
17
|
# osn-selenium: Advanced Selenium Wrapper with Async Support and Fingerprinting Protection
|
|
22
18
|
|
|
23
19
|
osn-selenium is a robust wrapper around Selenium WebDriver designed for automation of Blink-based browsers (Chrome, Edge, Yandex). It extends standard Selenium capabilities by providing native asynchronous support via Trio, deep integration with the Chrome DevTools Protocol (CDP), sophisticated browser fingerprint spoofing, and human-like user interaction simulation.
|
|
24
20
|
|
|
21
|
+
For more detailed information, please visit the [wiki page](https://github.com/oddshellnick/osn-selenium/wiki).
|
|
22
|
+
|
|
25
23
|
## Technologies
|
|
26
24
|
|
|
27
25
|
| Name | Badge | Description |
|
|
@@ -67,12 +65,23 @@ osn-selenium is a robust wrapper around Selenium WebDriver designed for automati
|
|
|
67
65
|
pip install osn-selenium
|
|
68
66
|
```
|
|
69
67
|
|
|
68
|
+
**With pip (beta versions):**
|
|
69
|
+
```bash
|
|
70
|
+
pip install -i https://test.pypi.org/simple/ osn_system_utils
|
|
71
|
+
```
|
|
72
|
+
|
|
70
73
|
* **With git:**
|
|
71
74
|
```bash
|
|
72
75
|
pip install git+https://github.com/oddshellnick/osn-selenium.git
|
|
73
76
|
```
|
|
74
77
|
*(Ensure you have git installed)*
|
|
75
78
|
|
|
79
|
+
* **With git (beta versions):**
|
|
80
|
+
```bash
|
|
81
|
+
pip install git+https://github.com/oddshellnick/osn-selenium.git@dev
|
|
82
|
+
```
|
|
83
|
+
*(Ensure you have git installed)*
|
|
84
|
+
|
|
76
85
|
2. **Install the required Python packages using pip:**
|
|
77
86
|
|
|
78
87
|
```bash
|
|
@@ -224,6 +233,10 @@ Utilities for executing JS and managing browser fingerprints.
|
|
|
224
233
|
|
|
225
234
|
## Notes
|
|
226
235
|
|
|
236
|
+
* **CDP Versioning and External Packages:**
|
|
237
|
+
This library supports a modular CDP (Chrome DevTools Protocol) architecture. Since standard Selenium distributions often deprecate or remove older protocol versions, we maintain a dedicated repository for all versions at [osn-selenium-cdp](https://github.com/oddshellnick/osn-selenium-cdp).
|
|
238
|
+
* **Manual Installation:** You can install specific CDP support by targeting the corresponding branch (e.g., `pip install git+https://github.com/oddshellnick/osn-selenium-cdp.git@v131`).
|
|
239
|
+
* **Structure Requirement:** If you choose to add or create CDP version packages manually, they **must strictly follow the directory structure** used in the `osn-selenium-cdp` repository. This ensures that the internal `MetaPathFinder` hook can correctly intercept and redirect imports from `selenium.webdriver.common.devtools`. Deviating from this structure will result in `CDPPackageError` or `ImportError`.
|
|
227
240
|
* **Concurrency Constraints in `trio_threads`:**
|
|
228
241
|
The `trio_threads` implementation is built using a unified `trio.Lock`. This means that every driver function and every associated instance (including `ActionChains`, `WebElement`, `Alert`, etc.) can execute only one operation at a time. Do not attempt to parallelize multiple operations (coroutines) within a single browser instance, as they will be queued sequentially. The primary purpose of this asynchronous implementation is to enable the simultaneous management of **multiple browser instances** within a single event loop, rather than concurrent interactions with one browser.
|
|
229
242
|
* **CDP Domains and Background Tasks:**
|