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.
- osn_selenium/__init__.py +1 -0
- osn_selenium/browsers_handler/__init__.py +70 -0
- osn_selenium/browsers_handler/_windows.py +130 -0
- osn_selenium/browsers_handler/types.py +20 -0
- osn_selenium/captcha_workers/__init__.py +26 -0
- osn_selenium/dev_tools/__init__.py +1 -0
- osn_selenium/dev_tools/_types.py +22 -0
- osn_selenium/dev_tools/domains/__init__.py +63 -0
- osn_selenium/dev_tools/domains/abstract.py +378 -0
- osn_selenium/dev_tools/domains/fetch.py +1295 -0
- osn_selenium/dev_tools/domains_default/__init__.py +1 -0
- osn_selenium/dev_tools/domains_default/fetch.py +155 -0
- osn_selenium/dev_tools/errors.py +89 -0
- osn_selenium/dev_tools/logger.py +558 -0
- osn_selenium/dev_tools/manager.py +1551 -0
- osn_selenium/dev_tools/utils.py +509 -0
- osn_selenium/errors.py +16 -0
- osn_selenium/types.py +118 -0
- osn_selenium/webdrivers/BaseDriver/__init__.py +1 -0
- osn_selenium/webdrivers/BaseDriver/_utils.py +37 -0
- osn_selenium/webdrivers/BaseDriver/flags.py +644 -0
- osn_selenium/webdrivers/BaseDriver/protocols.py +2135 -0
- osn_selenium/webdrivers/BaseDriver/trio_wrapper.py +71 -0
- osn_selenium/webdrivers/BaseDriver/webdriver.py +2626 -0
- osn_selenium/webdrivers/Blink/__init__.py +1 -0
- osn_selenium/webdrivers/Blink/flags.py +1349 -0
- osn_selenium/webdrivers/Blink/protocols.py +330 -0
- osn_selenium/webdrivers/Blink/webdriver.py +637 -0
- osn_selenium/webdrivers/Chrome/__init__.py +1 -0
- osn_selenium/webdrivers/Chrome/flags.py +192 -0
- osn_selenium/webdrivers/Chrome/protocols.py +228 -0
- osn_selenium/webdrivers/Chrome/webdriver.py +394 -0
- osn_selenium/webdrivers/Edge/__init__.py +1 -0
- osn_selenium/webdrivers/Edge/flags.py +192 -0
- osn_selenium/webdrivers/Edge/protocols.py +228 -0
- osn_selenium/webdrivers/Edge/webdriver.py +394 -0
- osn_selenium/webdrivers/Yandex/__init__.py +1 -0
- osn_selenium/webdrivers/Yandex/flags.py +192 -0
- osn_selenium/webdrivers/Yandex/protocols.py +211 -0
- osn_selenium/webdrivers/Yandex/webdriver.py +350 -0
- osn_selenium/webdrivers/__init__.py +1 -0
- osn_selenium/webdrivers/_functions.py +504 -0
- osn_selenium/webdrivers/js_scripts/check_element_in_viewport.js +18 -0
- osn_selenium/webdrivers/js_scripts/get_document_scroll_size.js +4 -0
- osn_selenium/webdrivers/js_scripts/get_element_css.js +6 -0
- osn_selenium/webdrivers/js_scripts/get_element_rect_in_viewport.js +9 -0
- osn_selenium/webdrivers/js_scripts/get_random_element_point_in_viewport.js +59 -0
- osn_selenium/webdrivers/js_scripts/get_viewport_position.js +4 -0
- osn_selenium/webdrivers/js_scripts/get_viewport_rect.js +6 -0
- osn_selenium/webdrivers/js_scripts/get_viewport_size.js +4 -0
- osn_selenium/webdrivers/js_scripts/open_new_tab.js +1 -0
- osn_selenium/webdrivers/js_scripts/stop_window_loading.js +1 -0
- osn_selenium/webdrivers/types.py +390 -0
- osn_selenium-0.0.0.dist-info/METADATA +710 -0
- osn_selenium-0.0.0.dist-info/RECORD +57 -0
- osn_selenium-0.0.0.dist-info/WHEEL +5 -0
- osn_selenium-0.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
from typing import (
|
|
3
|
+
Optional,
|
|
4
|
+
TypedDict,
|
|
5
|
+
Union
|
|
6
|
+
)
|
|
7
|
+
from selenium.webdriver.chrome.options import Options
|
|
8
|
+
from osn_selenium.webdrivers.Blink.flags import BlinkFeatures
|
|
9
|
+
from osn_selenium.webdrivers.types import (
|
|
10
|
+
FlagDefinition,
|
|
11
|
+
FlagType
|
|
12
|
+
)
|
|
13
|
+
from osn_selenium.webdrivers.Chrome.flags import (
|
|
14
|
+
ChromeArguments,
|
|
15
|
+
ChromeAttributes,
|
|
16
|
+
ChromeExperimentalOptions,
|
|
17
|
+
ChromeFlagsManager
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class YandexFlagsManager(ChromeFlagsManager):
|
|
22
|
+
"""
|
|
23
|
+
Manages Yandex Browser-specific options for Selenium WebDriver.
|
|
24
|
+
|
|
25
|
+
This class extends BrowserOptionsManager to provide specific configurations
|
|
26
|
+
for Yandex Browser options, such as experimental options and arguments.
|
|
27
|
+
|
|
28
|
+
Attributes:
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(
|
|
32
|
+
self,
|
|
33
|
+
browser_exe: Optional[Union[str, pathlib.Path]] = None,
|
|
34
|
+
start_page_url: Optional[str] = None,
|
|
35
|
+
flags_types: Optional[dict[str, FlagType]] = None,
|
|
36
|
+
flags_definitions: Optional[dict[str, FlagDefinition]] = None
|
|
37
|
+
):
|
|
38
|
+
"""
|
|
39
|
+
Initializes YandexOptionsManager.
|
|
40
|
+
|
|
41
|
+
Sets up the Yandex Browser options manager with specific option configurations for
|
|
42
|
+
debugging port, user agent, proxy, and BiDi protocol.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
yandex_flags_types = {}
|
|
46
|
+
|
|
47
|
+
if flags_types is not None:
|
|
48
|
+
yandex_flags_types.update(flags_types)
|
|
49
|
+
|
|
50
|
+
yandex_flags_definitions = {}
|
|
51
|
+
|
|
52
|
+
if flags_definitions is not None:
|
|
53
|
+
yandex_flags_definitions.update(flags_definitions)
|
|
54
|
+
|
|
55
|
+
super().__init__(
|
|
56
|
+
browser_exe=browser_exe,
|
|
57
|
+
start_page_url=start_page_url,
|
|
58
|
+
flags_types=yandex_flags_types,
|
|
59
|
+
flags_definitions=yandex_flags_definitions,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
def _renew_webdriver_options(self) -> Options:
|
|
63
|
+
"""
|
|
64
|
+
Creates and returns a new Options object.
|
|
65
|
+
|
|
66
|
+
Returns a fresh instance of `webdriver.ChromeOptions`, as Yandex Browser is based on Chromium,
|
|
67
|
+
allowing for a clean state of browser options to be configured.
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
Options: A new Selenium Yandex Browser options object, based on ChromeOptions.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
return Options()
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class YandexAttributes(ChromeAttributes, total=False):
|
|
77
|
+
"""
|
|
78
|
+
Typed dictionary for WebDriver attributes specific to Yandex browsers.
|
|
79
|
+
|
|
80
|
+
Attributes:
|
|
81
|
+
enable_bidi (Optional[bool]): Enables/disables BiDi (Bidirectional) protocol mapper.
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
pass
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class YandexExperimentalOptions(ChromeExperimentalOptions, total=False):
|
|
88
|
+
"""
|
|
89
|
+
Typed dictionary for experimental options specific to Yandex browsers.
|
|
90
|
+
|
|
91
|
+
Attributes:
|
|
92
|
+
debugger_address (Optional[str]): The address (IP:port) of the remote debugger.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
pass
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class YandexArguments(ChromeArguments, total=False):
|
|
99
|
+
"""
|
|
100
|
+
Typed dictionary for command-line arguments specific to Yandex browsers.
|
|
101
|
+
|
|
102
|
+
Attributes:
|
|
103
|
+
se_downloads_enabled (bool): Enables/disables Selenium downloads.
|
|
104
|
+
headless_mode (bool): Runs the browser in headless mode (without a UI).
|
|
105
|
+
mute_audio (bool): Mutes audio output from the browser.
|
|
106
|
+
no_first_run (bool): Prevents the browser from showing the "first run" experience.
|
|
107
|
+
disable_background_timer_throttling (bool): Disables throttling of background timers.
|
|
108
|
+
disable_backgrounding_occluded_windows (bool): Prevents backgrounding of occluded windows.
|
|
109
|
+
disable_hang_monitor (bool): Disables the browser's hang monitor.
|
|
110
|
+
disable_ipc_flooding_protection (bool): Disables IPC flooding protection.
|
|
111
|
+
disable_renderer_backgrounding (bool): Prevents renderer processes from being backgrounded.
|
|
112
|
+
disable_back_forward_cache (bool): Disables the Back-Forward Cache.
|
|
113
|
+
disable_notifications (bool): Disables web notifications.
|
|
114
|
+
disable_popup_blocking (bool): Disables the built-in popup blocker.
|
|
115
|
+
disable_prompt_on_repost (bool): Disables the prompt when reposting form data.
|
|
116
|
+
disable_sync (bool): Disables browser synchronization features.
|
|
117
|
+
disable_background_networking (bool): Disables background network activity.
|
|
118
|
+
disable_breakpad (bool): Disables the crash reporter.
|
|
119
|
+
disable_component_update (bool): Disables component updates.
|
|
120
|
+
disable_domain_reliability (bool): Disables domain reliability monitoring.
|
|
121
|
+
disable_new_content_rendering_timeout (bool): Disables timeout for new content rendering.
|
|
122
|
+
disable_threaded_animation (bool): Disables threaded animation.
|
|
123
|
+
disable_threaded_scrolling (bool): Disables threaded scrolling.
|
|
124
|
+
disable_checker_imaging (bool): Disables checker imaging.
|
|
125
|
+
disable_image_animation_resync (bool): Disables image animation resynchronization.
|
|
126
|
+
disable_partial_raster (bool): Disables partial rasterization.
|
|
127
|
+
disable_skia_runtime_opts (bool): Disables Skia runtime optimizations.
|
|
128
|
+
disable_dev_shm_usage (bool): Disables the use of /dev/shm (important for Docker).
|
|
129
|
+
disable_gpu (bool): Disables GPU hardware acceleration.
|
|
130
|
+
aggressive_cache_discard (bool): Enables aggressive discarding of cached data.
|
|
131
|
+
allow_running_insecure_content (bool): Allows running insecure content on HTTPS pages.
|
|
132
|
+
no_process_per_site (bool): Runs all sites in a single process (less secure, but saves memory).
|
|
133
|
+
enable_precise_memory_info (bool): Enables precise memory information reporting.
|
|
134
|
+
use_fake_device_for_media_stream (bool): Uses a fake camera/microphone for media streams.
|
|
135
|
+
use_fake_ui_for_media_stream (bool): Uses a fake UI for media stream requests.
|
|
136
|
+
deny_permission_prompts (bool): Automatically denies all permission prompts.
|
|
137
|
+
disable_external_intent_requests (bool): Disables external intent requests.
|
|
138
|
+
noerrdialogs (bool): Suppresses error dialogs.
|
|
139
|
+
enable_automation (bool): Enables automation features.
|
|
140
|
+
test_type (bool): Sets the browser to test mode.
|
|
141
|
+
remote_debugging_pipe (bool): Uses a pipe for remote debugging instead of a port.
|
|
142
|
+
silent_debugger_extension_api (bool): Silences debugger extension API warnings.
|
|
143
|
+
enable_logging_stderr (bool): Enables logging to stderr.
|
|
144
|
+
password_store_basic (bool): Uses a basic password store.
|
|
145
|
+
use_mock_keychain (bool): Uses a mock keychain for testing.
|
|
146
|
+
enable_crash_reporter_for_testing (bool): Enables crash reporter for testing purposes.
|
|
147
|
+
metrics_recording_only (bool): Records metrics without sending them.
|
|
148
|
+
no_pings (bool): Disables sending pings.
|
|
149
|
+
allow_pre_commit_input (bool): Allows pre-commit input.
|
|
150
|
+
deterministic_mode (bool): Runs the browser in a more deterministic mode.
|
|
151
|
+
run_all_compositor_stages_before_draw (bool): Runs all compositor stages before drawing.
|
|
152
|
+
enable_begin_frame_control (bool): Enables begin frame control.
|
|
153
|
+
in_process_gpu (bool): Runs the GPU process in-process.
|
|
154
|
+
block_new_web_contents (bool): Blocks new web contents (e.g., pop-ups).
|
|
155
|
+
new_window (bool): Opens a new window instead of a new tab.
|
|
156
|
+
no_service_autorun (bool): Disables service autorun.
|
|
157
|
+
process_per_tab (bool): Runs each tab in its own process.
|
|
158
|
+
single_process (bool): Runs the browser in a single process (less stable).
|
|
159
|
+
no_sandbox (bool): Disables the sandbox (less secure, but can fix some issues).
|
|
160
|
+
user_agent (Optional[str]): Sets a custom user agent string.
|
|
161
|
+
user_data_dir (Optional[str]): Specifies the user data directory.
|
|
162
|
+
proxy_server (Optional[str]): Specifies a proxy server to use.
|
|
163
|
+
remote_debugging_port (Optional[int]): Specifies the remote debugging port.
|
|
164
|
+
remote_debugging_address (Optional[str]): Specifies the remote debugging address.
|
|
165
|
+
use_file_for_fake_video_capture (Optional[Union[str, pathlib.Path]]): Uses a file for fake video capture.
|
|
166
|
+
autoplay_policy (Optional[AutoplayPolicyType]): Sets the autoplay policy.
|
|
167
|
+
log_level (Optional[LogLevelType]): Sets the browser's log level.
|
|
168
|
+
use_gl (Optional[UseGLType]): Specifies the GL backend to use.
|
|
169
|
+
force_color_profile (Optional[str]): Forces a specific color profile.
|
|
170
|
+
"""
|
|
171
|
+
|
|
172
|
+
pass
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
class YandexFlags(TypedDict, total=False):
|
|
176
|
+
"""
|
|
177
|
+
Typed dictionary representing a collection of all flag types for Yandex browsers.
|
|
178
|
+
|
|
179
|
+
This combines arguments, experimental options, attributes, and Blink features
|
|
180
|
+
that are specific to Yandex browsers.
|
|
181
|
+
|
|
182
|
+
Attributes:
|
|
183
|
+
argument (YandexArguments): Command-line arguments for the Yandex browser.
|
|
184
|
+
experimental_option (YandexExperimentalOptions): Experimental options for WebDriver specific to Yandex.
|
|
185
|
+
attribute (YandexAttributes): WebDriver attributes specific to Yandex.
|
|
186
|
+
blink_feature (BlinkFeatures): Blink-specific feature flags.
|
|
187
|
+
"""
|
|
188
|
+
|
|
189
|
+
argument: YandexArguments
|
|
190
|
+
experimental_option: YandexExperimentalOptions
|
|
191
|
+
attribute: YandexAttributes
|
|
192
|
+
blink_feature: BlinkFeatures
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
from osn_selenium.types import WindowRect
|
|
3
|
+
from osn_selenium.webdrivers.types import _any_flags_mapping
|
|
4
|
+
from osn_selenium.webdrivers.Yandex.flags import YandexFlagsManager
|
|
5
|
+
from typing import (
|
|
6
|
+
Optional,
|
|
7
|
+
Protocol,
|
|
8
|
+
TYPE_CHECKING,
|
|
9
|
+
Union,
|
|
10
|
+
runtime_checkable
|
|
11
|
+
)
|
|
12
|
+
from osn_selenium.webdrivers.Chrome.protocols import (
|
|
13
|
+
TrioChromeWebDriverWrapperProtocol
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
if TYPE_CHECKING:
|
|
18
|
+
from osn_selenium.webdrivers.Yandex.webdriver import YandexWebDriver, YandexFlags
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@runtime_checkable
|
|
22
|
+
class TrioYandexWebDriverWrapperProtocol(TrioChromeWebDriverWrapperProtocol, Protocol):
|
|
23
|
+
"""
|
|
24
|
+
Wraps YandexWebDriver methods for asynchronous execution using Trio.
|
|
25
|
+
|
|
26
|
+
This class acts as a proxy to a `BrowserWebDriver` instance. It intercepts
|
|
27
|
+
method calls and executes them in a separate thread using `trio.to_thread.run_sync`,
|
|
28
|
+
allowing synchronous WebDriver operations to be called from asynchronous Trio code
|
|
29
|
+
without blocking the event loop. Properties and non-callable attributes are accessed directly.
|
|
30
|
+
|
|
31
|
+
Attributes:
|
|
32
|
+
_webdriver (BrowserWebDriver): The underlying synchronous BrowserWebDriver instance.
|
|
33
|
+
_excluding_functions (list[str]): A list of attribute names on the wrapped object
|
|
34
|
+
that should *not* be accessible through this wrapper,
|
|
35
|
+
typically because they are irrelevant or dangerous
|
|
36
|
+
in an async context handled by the wrapper.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
_webdriver: "YandexWebDriver"
|
|
40
|
+
_webdriver_flags_manager: "YandexFlagsManager"
|
|
41
|
+
|
|
42
|
+
def reset_settings(
|
|
43
|
+
self,
|
|
44
|
+
flags: Optional[Union["YandexFlags", _any_flags_mapping]] = None,
|
|
45
|
+
browser_exe: Optional[Union[str, pathlib.Path]] = None,
|
|
46
|
+
browser_name_in_system: Optional[str] = None,
|
|
47
|
+
use_browser_exe: Optional[bool] = None,
|
|
48
|
+
start_page_url: str = "",
|
|
49
|
+
window_rect: Optional[WindowRect] = None,
|
|
50
|
+
trio_tokens_limit: Union[int, float] = 40,
|
|
51
|
+
):
|
|
52
|
+
"""
|
|
53
|
+
Resets various configurable browser settings to their specified or default values.
|
|
54
|
+
|
|
55
|
+
This method allows for reconfiguring the WebDriver's operational parameters,
|
|
56
|
+
such as browser flags, executable path, start URL, window dimensions, and
|
|
57
|
+
concurrency limits. It is crucial that the browser session is *not* active
|
|
58
|
+
when this method is called; otherwise, a warning will be issued, and no changes
|
|
59
|
+
will be applied.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
flags (Optional[Union[YandexFlags, Mapping[str, Any]]]): New browser flags to apply.
|
|
63
|
+
If provided, existing flags are cleared and replaced with these.
|
|
64
|
+
If `None`, all custom flags are cleared, and the browser will start with default flags.
|
|
65
|
+
browser_exe (Optional[Union[str, pathlib.Path]]): The explicit path to the browser executable.
|
|
66
|
+
If provided, this path will be used. If `None`, the executable path managed by the
|
|
67
|
+
flags manager will be cleared, and then potentially re-detected based on
|
|
68
|
+
`use_browser_exe` and `browser_name_in_system`.
|
|
69
|
+
browser_name_in_system (Optional[str]): The common name of the browser (e.g., "Chrome", "Edge").
|
|
70
|
+
Used in conjunction with `use_browser_exe` to automatically detect the browser executable path.
|
|
71
|
+
This parameter only takes effect if `use_browser_exe` is explicitly `True` or `False`.
|
|
72
|
+
If `None`, no automatic detection based on name will occur through this method call.
|
|
73
|
+
use_browser_exe (Optional[bool]): Controls the automatic detection of the browser executable.
|
|
74
|
+
If `True` (and `browser_name_in_system` is provided), the browser executable path
|
|
75
|
+
will be automatically detected if `browser_exe` is `None`.
|
|
76
|
+
If `False` (and `browser_name_in_system` is provided), any existing `browser_exe`
|
|
77
|
+
path in the flags manager will be cleared.
|
|
78
|
+
If `None`, the current `use_browser_exe` state is maintained for the `_detect_browser_exe` logic.
|
|
79
|
+
start_page_url (str): The URL that the browser will attempt to navigate to
|
|
80
|
+
immediately after starting. Defaults to an empty string.
|
|
81
|
+
window_rect (Optional[WindowRect]): The initial window size and position settings.
|
|
82
|
+
If `None`, it defaults to a new `WindowRect()` instance, effectively resetting
|
|
83
|
+
to the browser's default window behavior.
|
|
84
|
+
trio_tokens_limit (Union[int, float]): The maximum number of concurrent synchronous
|
|
85
|
+
WebDriver operations allowed by the Trio capacity limiter. Defaults to 40.
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
...
|
|
89
|
+
|
|
90
|
+
def restart_webdriver(
|
|
91
|
+
self,
|
|
92
|
+
flags: Optional[Union["YandexFlags", _any_flags_mapping]] = None,
|
|
93
|
+
browser_exe: Optional[Union[str, pathlib.Path]] = None,
|
|
94
|
+
browser_name_in_system: Optional[str] = None,
|
|
95
|
+
use_browser_exe: Optional[bool] = None,
|
|
96
|
+
start_page_url: Optional[str] = None,
|
|
97
|
+
window_rect: Optional[WindowRect] = None,
|
|
98
|
+
trio_tokens_limit: Optional[Union[int, float]] = None,
|
|
99
|
+
):
|
|
100
|
+
"""
|
|
101
|
+
Restarts the WebDriver and browser session gracefully.
|
|
102
|
+
|
|
103
|
+
Performs a clean restart by first closing the existing WebDriver session and browser
|
|
104
|
+
(using `close_webdriver`), and then initiating a new session (using `start_webdriver`)
|
|
105
|
+
with potentially updated settings. If settings arguments are provided, they override
|
|
106
|
+
the existing settings for the new session; otherwise, the current settings are used.
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
flags (Optional[Union[YandexFlags, Mapping[str, Any]]]): Override flags for the new session.
|
|
110
|
+
If provided, these flags will be applied. If `None`, current settings are used.
|
|
111
|
+
browser_exe (Optional[Union[str, pathlib.Path]]): Override browser executable for the new session.
|
|
112
|
+
If provided, this path will be used. If `None`, current settings are used.
|
|
113
|
+
browser_name_in_system (Optional[str]): Override browser name for auto-detection for the new session.
|
|
114
|
+
Only takes effect if `use_browser_exe` is also provided. If `None`, current settings are used.
|
|
115
|
+
use_browser_exe (Optional[bool]): Override auto-detection behavior for the new session.
|
|
116
|
+
If provided, this boolean determines if the browser executable is auto-detected.
|
|
117
|
+
If `None`, current settings are used.
|
|
118
|
+
start_page_url (Optional[str]): Override start page URL for the new session.
|
|
119
|
+
If provided, this URL will be used. If `None`, current setting is used.
|
|
120
|
+
window_rect (Optional[WindowRect]): Override window rectangle for the new session.
|
|
121
|
+
If provided, these dimensions will be used. If `None`, current settings are used.
|
|
122
|
+
trio_tokens_limit (Optional[Union[int, float]]): Override Trio token limit for the new session.
|
|
123
|
+
If provided, this limit will be used. If `None`, current setting is used.
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
...
|
|
127
|
+
|
|
128
|
+
def start_webdriver(
|
|
129
|
+
self,
|
|
130
|
+
flags: Optional[Union["YandexFlags", _any_flags_mapping]] = None,
|
|
131
|
+
browser_exe: Optional[Union[str, pathlib.Path]] = None,
|
|
132
|
+
browser_name_in_system: Optional[str] = None,
|
|
133
|
+
use_browser_exe: Optional[bool] = None,
|
|
134
|
+
start_page_url: Optional[str] = None,
|
|
135
|
+
window_rect: Optional[WindowRect] = None,
|
|
136
|
+
trio_tokens_limit: Optional[Union[int, float]] = None,
|
|
137
|
+
):
|
|
138
|
+
"""
|
|
139
|
+
Starts the WebDriver service and the browser session.
|
|
140
|
+
|
|
141
|
+
Initializes and starts the WebDriver instance and the associated browser process.
|
|
142
|
+
It first updates settings based on provided parameters (if the driver is not already running),
|
|
143
|
+
checks if a browser process needs to be started, starts it if necessary using Popen,
|
|
144
|
+
waits for it to become active, and then creates the WebDriver client instance (`self.driver`).
|
|
145
|
+
|
|
146
|
+
Args:
|
|
147
|
+
flags (Optional[Union[YandexFlags, Mapping[str, Any]]]): Override flags for this start.
|
|
148
|
+
If provided, these flags will be applied. If `None`, current settings are used.
|
|
149
|
+
browser_exe (Optional[Union[str, pathlib.Path]]): Override browser executable path for this start.
|
|
150
|
+
If provided, this path will be used. If `None`, current settings are used.
|
|
151
|
+
browser_name_in_system (Optional[str]): Override browser name for auto-detection for this start.
|
|
152
|
+
Only takes effect if `use_browser_exe` is also provided. If `None`, current settings are used.
|
|
153
|
+
use_browser_exe (Optional[bool]): Override auto-detection behavior for this start.
|
|
154
|
+
If provided, this boolean determines if the browser executable is auto-detected.
|
|
155
|
+
If `None`, current settings are used.
|
|
156
|
+
start_page_url (Optional[str]): Override start page URL for this start.
|
|
157
|
+
If provided, this URL will be used. If `None`, current setting is used.
|
|
158
|
+
window_rect (Optional[WindowRect]): Override window rectangle for this start.
|
|
159
|
+
If provided, these dimensions will be used. If `None`, current settings are used.
|
|
160
|
+
trio_tokens_limit (Optional[Union[int, float]]): Override Trio token limit for this start.
|
|
161
|
+
If provided, this limit will be used. If `None`, current setting is used.
|
|
162
|
+
"""
|
|
163
|
+
|
|
164
|
+
...
|
|
165
|
+
|
|
166
|
+
def update_settings(
|
|
167
|
+
self,
|
|
168
|
+
flags: Optional[Union["YandexFlags", _any_flags_mapping]] = None,
|
|
169
|
+
browser_exe: Optional[Union[str, pathlib.Path]] = None,
|
|
170
|
+
browser_name_in_system: Optional[str] = None,
|
|
171
|
+
use_browser_exe: Optional[bool] = None,
|
|
172
|
+
start_page_url: Optional[str] = None,
|
|
173
|
+
window_rect: Optional[WindowRect] = None,
|
|
174
|
+
trio_tokens_limit: Optional[Union[int, float]] = None,
|
|
175
|
+
):
|
|
176
|
+
"""
|
|
177
|
+
Updates various browser settings selectively without resetting others.
|
|
178
|
+
|
|
179
|
+
This method allows for dynamic updating of browser settings. Only the settings
|
|
180
|
+
for which a non-None value is provided will be updated. Settings passed as `None`
|
|
181
|
+
will retain their current values. This method can be called whether the browser
|
|
182
|
+
is active or not, but some changes might only take effect after the browser is
|
|
183
|
+
restarted.
|
|
184
|
+
|
|
185
|
+
Args:
|
|
186
|
+
flags (Optional[Union[YandexFlags, Mapping[str, Any]]]): New browser flags to update.
|
|
187
|
+
If provided, these flags will be merged with or overwrite existing flags
|
|
188
|
+
within the flags manager. If `None`, existing flags remain unchanged.
|
|
189
|
+
browser_exe (Optional[Union[str, pathlib.Path]]): The new path to the browser executable.
|
|
190
|
+
If provided, this path will be set in the flags manager. If `None`, the
|
|
191
|
+
current browser executable path remains unchanged.
|
|
192
|
+
browser_name_in_system (Optional[str]): The common name of the browser (e.g., "Chrome", "Edge").
|
|
193
|
+
Used in conjunction with `use_browser_exe` to automatically detect the browser executable path.
|
|
194
|
+
This parameter only takes effect if `use_browser_exe` is explicitly provided.
|
|
195
|
+
If `None`, no automatic detection based on name will occur through this method call.
|
|
196
|
+
use_browser_exe (Optional[bool]): Controls the automatic detection of the browser executable.
|
|
197
|
+
If `True` (and `browser_name_in_system` is provided), the browser executable path
|
|
198
|
+
will be automatically detected if `browser_exe` is `None`.
|
|
199
|
+
If `False` (and `browser_name_in_system` is provided), any existing `browser_exe`
|
|
200
|
+
path in the flags manager will be cleared.
|
|
201
|
+
If `None`, the current `use_browser_exe` state is maintained for the `_detect_browser_exe` logic.
|
|
202
|
+
start_page_url (Optional[str]): The new URL that the browser will attempt to navigate to
|
|
203
|
+
immediately after starting. If `None`, the current start page URL remains unchanged.
|
|
204
|
+
window_rect (Optional[WindowRect]): The new window size and position settings.
|
|
205
|
+
If `None`, the current window rectangle settings remain unchanged.
|
|
206
|
+
trio_tokens_limit (Optional[Union[int, float]]): The new maximum number of concurrent
|
|
207
|
+
asynchronous operations allowed by the Trio capacity limiter. If `None`, the
|
|
208
|
+
current limit remains unchanged.
|
|
209
|
+
"""
|
|
210
|
+
|
|
211
|
+
...
|