### Basic Browser Automation with nodriver Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/README.md A simple asynchronous example demonstrating how to start a browser instance, navigate to a URL, and perform further actions. ```python import nodriver as uc async def main(): browser = await uc.start() page = await browser.get('https://www.nowsecure.nl') ... further code ... if __name__ == '__main__': # since asyncio.run never worked (for me) uc.loop().run_until_complete(main()) ``` -------------------------------- ### Basic Browser Automation with nodriver Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_sources/readme.rst.txt A simple asynchronous example demonstrating how to start a browser, navigate to a URL, take a screenshot, get page content, scroll down, and find all elements with a 'src' attribute. ```python import asyncio import nodriver as uc async def main(): browser = await uc.start() page = await browser.get('https://www.nowsecure.nl') await page.save_screenshot() await page.get_content() await page.scroll_down(150) elems = await page.select_all('*[src]') for elem in elems: pass ``` -------------------------------- ### Start Profiler Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/profiler.html Starts the CPU profiler. Use this to begin recording CPU profiles. ```python def start() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]: cmd_dict: T_JSON_DICT = { 'method': 'Profiler.start', } json = yield cmd_dict ``` -------------------------------- ### start Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/markdown/nodriver/classes/browser.md Launches the actual browser instance. ```APIDOC ## async start() ### Description Launches the actual browser. ### Return type Browser ``` -------------------------------- ### start_desktop_mirroring Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/cast.html Starts mirroring the desktop to the sink. ```APIDOC ## start_desktop_mirroring ### Description Starts mirroring the desktop to the sink. ### Method POST ### Endpoint /json/protocol ### Parameters #### Query Parameters - **sinkName** (string) - Required - The name of the sink to mirror to. ### Request Example ```json { "method": "Cast.startDesktopMirroring", "params": { "sinkName": "My Sink Name" } } ``` ### Response #### Success Response (200) This method does not return a response body, but it yields a command dictionary. #### Response Example ```json { "example": "null" } ``` ``` -------------------------------- ### start() Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/markdown/nodriver/cdp/profiler.md Starts the profiler. This command is a generator function. ```APIDOC ## start() ### Description Starts the profiler. This command is a generator function. ### Method Generator ### Return Type Generator[Dict[str, Any], Dict[str, Any], None] ``` -------------------------------- ### Start Screencast Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/nodriver/cdp/page.html Starts sending each frame using the `screencastFrame` event. This method is EXPERIMENTAL. ```APIDOC ## start_screencast format=None, quality=None, max_width=None, max_height=None, every_nth_frame=None ### Description Starts sending each frame using the `screencastFrame` event. **EXPERIMENTAL** ### Parameters #### Path Parameters - **format** (string) - Optional - Image compression format. - **quality** (Optional[int]) - Optional - Compression quality from range [0..100]. - **max_width** (Optional[int]) - Optional - Maximum screenshot width. - **max_height** (Optional[int]) - Optional - Maximum screenshot height. - **every_nth_frame** (Optional[int]) - Optional - Send every n-th frame. ### Return type Generator[Dict[str, Any], Dict[str, Any], None] ``` -------------------------------- ### Concrete example: Twitter account creation Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_sources/nodriver/quickstart.rst.txt A detailed example demonstrating how to automate parts of the Twitter account creation process, including finding and clicking elements, and handling conditional input fields. ```python import asyncio import random import string import logging logging.basicConfig(level=30) import nodriver as uc months = [ "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december", ] async def main(): driver = await uc.start() tab = await driver.get("https://twitter.com") # wait for text to appear instead of a static number of seconds to wait # this does not always work as expected, due to speed. print('finding the "create account" button') create_account = await tab.find("create account", best_match=True) print('"create account" => click') await create_account.click() print("finding the email input field") email = await tab.select("input[type=email]") # sometimes, email field is not shown, because phone is being asked instead # when this occurs, find the small text which says "use email instead" if not email: use_mail_instead = await tab.find("use email instead") ``` -------------------------------- ### start Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/nodriver/cdp/tracing.md Starts trace events collection. This method allows for detailed performance profiling by capturing various trace events. ```APIDOC ## start ### Description Starts trace events collection. This method allows for detailed performance profiling by capturing various trace events. ### Method Signature start(categories: str | None = None, options: str | None = None, buffer_usage_reporting_interval: float | None = None, transfer_mode: str | None = None, stream_format: [StreamFormat](#nodriver.cdp.tracing.StreamFormat) | None = None, stream_compression: [StreamCompression](#nodriver.cdp.tracing.StreamCompression) | None = None, trace_config: [TraceConfig](#nodriver.cdp.tracing.TraceConfig) | None = None, perfetto_config: str | None = None, tracing_backend: [TracingBackend](#nodriver.cdp.tracing.TracingBackend) | None = None) → Generator[Dict[str, Any], Dict[str, Any], None] ### Parameters #### Optional Parameters - **categories** (str | None) - **(DEPRECATED)** **(EXPERIMENTAL)** Category/tag filter. - **options** (str | None) - **(DEPRECATED)** **(EXPERIMENTAL)** Tracing options. - **buffer_usage_reporting_interval** (float | None) - **(EXPERIMENTAL)** If set, the agent will issue bufferUsage events at this interval, specified in milliseconds. - **transfer_mode** (str | None) - Whether to report trace events as series of dataCollected events or to save trace to a stream (defaults to `ReportEvents`). - **stream_format** ([StreamFormat](#nodriver.cdp.tracing.StreamFormat) | None) - Trace data format to use. This only applies when using `ReturnAsStream` transfer mode (defaults to `json`). - **stream_compression** ([StreamCompression](#nodriver.cdp.tracing.StreamCompression) | None) - **(EXPERIMENTAL)** Compression format to use. This only applies when using `ReturnAsStream` transfer mode (defaults to `none`). - **trace_config** ([TraceConfig](#nodriver.cdp.tracing.TraceConfig) | None) - Configuration for trace events. - **perfetto_config** (str | None) - **(EXPERIMENTAL)** Base64-encoded serialized perfetto.protos.TraceConfig protobuf message. When specified, the parameters `categories`, `options`, `traceConfig` are ignored. (Encoded as a base64 string when passed over JSON). - **tracing_backend** ([TracingBackend](#nodriver.cdp.tracing.TracingBackend) | None) - **(EXPERIMENTAL)** Backend type (defaults to `auto`). ### Return Value A generator yielding trace events. ``` -------------------------------- ### start_sampling Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/heap_profiler.html Starts the sampling heap profiler. ```APIDOC ## start_sampling ### Description Starts the sampling heap profiler. This method collects information about heap memory usage over time. ### Method `start_sampling` ### Parameters #### Query Parameters * **sampling_interval** (float) - Optional - Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes. * **include_objects_collected_by_major_gc** (boolean) - Optional - By default, the sampling heap profiler reports only objects which are still alive when the profile is returned via getSamplingProfile or stopSampling, which is useful for determining what functions contribute the most to steady-state memory usage. This flag instructs the sampling heap profiler to also include information about objects discarded by major GC, which will show which functions cause large temporary memory usage or long GC pauses. * **include_objects_collected_by_minor_gc** (boolean) - Optional - By default, the sampling heap profiler reports only objects which are still alive when the profile is returned via getSamplingProfile or stopSampling, which is useful for determining what functions contribute the most to steady-state memory usage. This flag instructs the sampling heap profiler to also include information about objects discarded by minor GC, which is useful when tuning a latency-sensitive application for minimal GC activity. ### Response None ``` -------------------------------- ### Start Screencast Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/page.html Starts sending each frame using the `screencastFrame` event. This is an experimental feature. Optional parameters include format, quality, max width, max height, and every nth frame. ```python def start_screencast( format_: typing.Optional[str] = None, quality: typing.Optional[int] = None, max_width: typing.Optional[int] = None, max_height: typing.Optional[int] = None, every_nth_frame: typing.Optional[int] = None ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]: ''' Starts sending each frame using the `screencastFrame` event. **EXPERIMENTAL** :param format_: *(Optional)* Image compression format. ``` -------------------------------- ### start_tab_mirroring Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/cast.html Starts mirroring the tab to the sink. ```APIDOC ## start_tab_mirroring ### Description Starts mirroring the tab to the sink. ### Method POST ### Endpoint /json/protocol ### Parameters #### Query Parameters - **sinkName** (string) - Required - The name of the sink to mirror to. ### Request Example ```json { "method": "Cast.startTabMirroring", "params": { "sinkName": "My Sink Name" } } ``` ### Response #### Success Response (200) This method does not return a response body, but it yields a command dictionary. #### Response Example ```json { "example": "null" } ``` ``` -------------------------------- ### start Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/nodriver/cdp/profiler.html Starts the profiler. This method returns a generator that yields profiling data. ```APIDOC ## start ### Description Starts the profiler. ### Return Type Generator[Dict[str, Any], Dict[str, Any], None] ``` -------------------------------- ### start_sampling Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/memory.html Start collecting native memory profile. ```APIDOC ## Memory.startSampling ### Description Start collecting native memory profile. ### Method POST ### Endpoint /json/protocol/Memory.startSampling ### Parameters #### Request Body - **samplingInterval** (integer) - Optional - Average number of bytes between samples. - **suppressRandomness** (boolean) - Optional - Do not randomize intervals between samples. ### Response #### Success Response (200) - **result** (object) - An empty object. #### Response Example ```json { "result": {} } ``` ``` -------------------------------- ### start_screencast Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/nodriver/cdp/page.html Starts a screencast of the page. ```APIDOC ## start_screencast ### Description Starts a screencast of the page. ### Method POST ### Endpoint /page/start_screencast ### Parameters #### Request Body - **format** (string) - Optional - The format of the screencast frames. Possible values: "image/png", "image/jpeg". - **quality** (integer) - Optional - The quality of the JPEG images. - **maxWidth** (integer) - Optional - The maximum width of the screencast frames. - **maxHeight** (integer) - Optional - The maximum height of the screencast frames. - **everyNthFrame** (integer) - Optional - Capture every Nth frame. ### Request Example { "format": "image/jpeg", "quality": 80 } ### Response #### Success Response (200) An empty object. ### Response Example {} ``` -------------------------------- ### Start Heap Object Tracking Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/heap_profiler.html Starts tracking heap objects. This method can optionally be configured to track allocations. ```python params: T_JSON_DICT = dict() if track_allocations is not None: params['trackAllocations'] = track_allocations ``` -------------------------------- ### start_screencast Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_sources/nodriver/cdp/page.rst.txt Starts capturing screenshots of the page. ```APIDOC ## start_screencast ### Description Starts capturing screenshots of the page. ### Parameters * **options** (dict, optional) - Additional options for screencast. ``` -------------------------------- ### Start Tracing Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/tracing.html Starts trace event collection. Configure tracing with categories, options, buffer usage reporting, transfer mode, stream format/compression, trace config, perfetto config, and tracing backend. ```python def start( categories: typing.Optional[str] = None, options: typing.Optional[str] = None, buffer_usage_reporting_interval: typing.Optional[float] = None, transfer_mode: typing.Optional[str] = None, stream_format: typing.Optional[StreamFormat] = None, stream_compression: typing.Optional[StreamCompression] = None, trace_config: typing.Optional[TraceConfig] = None, perfetto_config: typing.Optional[str] = None, tracing_backend: typing.Optional[TracingBackend] = None ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]: ''' ``` -------------------------------- ### Start Heap Sampling Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/heap_profiler.html Starts collecting a sampling heap profile. Configurable options include the sampling interval and whether to include objects collected by major or minor garbage collection. ```python params: T_JSON_DICT = dict() if sampling_interval is not None: params['samplingInterval'] = sampling_interval if include_objects_collected_by_major_gc is not None: params['includeObjectsCollectedByMajorGC'] = include_objects_collected_by_major_gc if include_objects_collected_by_minor_gc is not None: params['includeObjectsCollectedByMinorGC'] = include_objects_collected_by_minor_gc cmd_dict: T_JSON_DICT = { 'method': 'HeapProfiler.startSampling', 'params': params, } json = yield cmd_dict ``` -------------------------------- ### start Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/nodriver/cdp/tracing.html Starts trace events collection. This method allows for configuring various aspects of trace collection, including categories, transfer modes, and data formats. ```APIDOC ## start ### Description Start trace events collection. This is an experimental feature. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **categories** (`Optional[str]`) - **(DEPRECATED)** **(EXPERIMENTAL)** Category/tag filter. * **options** (`Optional[str]`) - **(DEPRECATED)** **(EXPERIMENTAL)** Tracing options. * **buffer_usage_reporting_interval** (`Optional[float]`) - **(EXPERIMENTAL)** If set, the agent will issue bufferUsage events at this interval, specified in milliseconds. * **transfer_mode** (`Optional[str]`) - Whether to report trace events as series of dataCollected events or to save trace to a stream (defaults to `ReportEvents`). * **stream_format** (`Optional[StreamFormat]`) - Trace data format to use. This only applies when using `ReturnAsStream` transfer mode (defaults to `json`). * **stream_compression** (`Optional[StreamCompression]`) - **(EXPERIMENTAL)** Compression format to use. This only applies when using `ReturnAsStream` transfer mode (defaults to `none`). * **trace_config** (`Optional[TraceConfig]`) - Configuration for tracing. * **perfetto_config** (`Optional[PerfettoConfig]`) - Configuration for Perfetto tracing backend. * **tracing_backend** (`Optional[TracingBackend]`) - Tracing backend to use. ``` -------------------------------- ### start Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/markdown/nodriver/cdp/tracing.md Starts trace events collection. This method allows for configuring various aspects of tracing, including categories, buffer usage reporting, transfer modes, stream formats, compression, and specific trace configurations. ```APIDOC ## start(categories=None, options=None, buffer_usage_reporting_interval=None, transfer_mode=None, stream_format=None, stream_compression=None, trace_config=None, perfetto_config=None, tracing_backend=None) Start trace events collection. * **Parameters:** * **categories** ([`Optional`][`str`]) – **(DEPRECATED)** **(EXPERIMENTAL)** *(Optional)* Category/tag filter * **options** ([`Optional`][`str`]) – **(DEPRECATED)** **(EXPERIMENTAL)** *(Optional)* Tracing options * **buffer_usage_reporting_interval** ([`Optional`][`float`]) – **(EXPERIMENTAL)** *(Optional)* If set, the agent will issue bufferUsage events at this interval, specified in milliseconds * **transfer_mode** ([`Optional`][`str`]) – *(Optional)* Whether to report trace events as series of dataCollected events or to save trace to a stream (defaults to ``ReportEvents```). * **stream_format** ([`Optional`][`StreamFormat`]) – *(Optional)* Trace data format to use. This only applies when using ```ReturnAsStream``` transfer mode (defaults to ```json```). * **stream_compression** ([`Optional`][`StreamCompression`]) – **(EXPERIMENTAL)** *(Optional)* Compression format to use. This only applies when using ```ReturnAsStream``` transfer mode (defaults to ```none```) * **trace_config** ([`Optional`][`TraceConfig`]) – *(Optional)* * **perfetto_config** ([`Optional`][`str`]) – **(EXPERIMENTAL)** *(Optional)* Base64-encoded serialized perfetto.protos.TraceConfig protobuf message When specified, the parameters ```categories```, ```options```, ```traceConfig``` are ignored. (Encoded as a base64 string when passed over JSON) * **tracing_backend** ([`Optional`][`TracingBackend`]) – **(EXPERIMENTAL)** *(Optional)* Backend type (defaults to ```auto``) * **Return type:** [`Generator`][`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`] ``` -------------------------------- ### Get Installability Errors Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/page.html Retrieves installability errors for the current page. This is an experimental API. ```python def get_installability_errors() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[InstallabilityError]]: ''' **EXPERIMENTAL** :returns: ''' cmd_dict: T_JSON_DICT = { 'method': 'Page.getInstallabilityErrors', } json = yield cmd_dict ``` -------------------------------- ### start_tracking_heap_objects Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/heap_profiler.html Starts tracking heap objects. ```APIDOC ## start_tracking_heap_objects ### Description Starts tracking heap objects. This method can be used to track memory allocations over time. ### Method `start_tracking_heap_objects` ### Parameters #### Query Parameters * **track_allocations** (boolean) - Optional - Specifies whether to track allocations. ### Response None ``` -------------------------------- ### Browser.start() Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/nodriver/classes/browser.html Launches the actual browser instance. This method can be configured with various experimental options for proxy settings and network access. ```APIDOC ## Browser.start() ### Description Launches the actual browser instance. ### Parameters * **dispose_on_detach** (`bool`) - Optional - If specified, disposes this context when debugging session disconnects. * **proxy_server** (`str`) - Optional - Proxy server configuration. * **proxy_bypass_list** (`List[str]`) - Optional - Proxy bypass list. * **origins_with_universal_network_access** (`List[str]`) - Optional - An optional list of origins to grant unlimited cross-origin access to. ### Returns * `Browser` - An instance of the Browser class. ``` -------------------------------- ### Get Installability Errors Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/page.html Retrieves a list of errors that prevent a web page from being installed as a PWA. This method is useful for debugging PWA installation issues. ```python cmd_dict: T_JSON_DICT = { 'method': 'Page.getInstallabilityErrors', } json = yield cmd_dict return [InstallabilityError.from_json(i) for i in json['installabilityErrors']] ``` -------------------------------- ### start_worker Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/service_worker.html Starts the installed service worker. If the service worker is already running, this command does nothing. ```APIDOC ## start_worker ### Description Starts the installed service worker. If the service worker is already running, this command does nothing. ### Method POST ### Endpoint /ServiceWorker.startWorker ### Parameters #### Query Parameters - **scopeURL** (string) - Required - The scope URL of the service worker to start. ``` -------------------------------- ### start Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/core/browser.html Launches the actual browser instance. If the browser is already running, it will attempt to connect to the existing instance or warn the user. ```APIDOC ## start ### Description Launches the actual browser instance. If the browser is already running, it will attempt to connect to the existing instance or warn the user. ### Method `async def start(self=None) -> Browser:` ### Parameters None ### Return Value - **Browser** - The Browser instance. ### Notes - If called without an existing instance, it's recommended to use `await Browser.create()`. - If the browser executable is not found, a `FileNotFoundError` will be raised, prompting the user to specify the path. ### Example ```python # Example usage (assuming 'browser' is an instance of nodriver.Browser) # await browser.start() ``` ``` -------------------------------- ### launch() Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/genindex.html Launches a new browser instance. ```APIDOC ## launch() ### Description Launches a new browser instance. ### Method This is a function call within the nodriver.cdp.pwa module. ### Parameters None explicitly documented. ### Request Example ```python import nodriver.cdp.pwa nodriver.cdp.pwa.launch() ``` ### Response None explicitly documented. ``` -------------------------------- ### FrameStartedNavigating Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/page.html Fired when a frame has started navigating. This can be fired for a single navigation, for example, when a same-document navigation becomes a cross-document navigation. ```APIDOC ## FrameStartedNavigating Event ### Description Fired when a frame has started navigating. This event is relevant for both same-document and cross-document navigations. ### Event Details - **frame_id** (FrameId) - ID of the frame that is being navigated. - **url** (str) - The URL the navigation started with. The final URL can be different. - **loader_id** (network.LoaderId) - Loader identifier. This ID remains the same for same-document navigations but changes for cross-document navigations. - **navigation_type** (str) - The type of navigation that has started. ``` -------------------------------- ### Get Supported Tracing Categories Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/tracing.html Retrieves a list of supported tracing categories. Use this to discover available categories before starting a trace. ```python def get_categories() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[str]]: ''' Gets supported tracing categories. **EXPERIMENTAL** :returns: A list of supported tracing categories. ''' cmd_dict: T_JSON_DICT = { 'method': 'Tracing.getCategories', } json = yield cmd_dict return [str(i) for i in json['categories']] ``` -------------------------------- ### Start Desktop Mirroring Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/cast.html Initiates mirroring of the entire desktop to a specified casting sink. Requires the sink's name. ```python def start_desktop_mirroring( sink_name: str ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]: ''' Starts mirroring the desktop to the sink. :param sink_name: ''' params: T_JSON_DICT = dict() params['sinkName'] = sink_name cmd_dict: T_JSON_DICT = { 'method': 'Cast.startDesktopMirroring', 'params': params, } json = yield cmd_dict ``` -------------------------------- ### Basic Usage Example Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_sources/index.rst.txt Demonstrates the fundamental way to initialize and use the browser for web scraping tasks. ```python import nodriver async def main(): browser = await nodriver.browse() await browser.goto("https://www.google.com") await browser.sleep(2) await browser.close() nodriver.run(main()) ``` -------------------------------- ### Launch PWA Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/nodriver/cdp/pwa.html Launches an installed Progressive Web App. An optional URL can be provided to launch a specific page within the app instead of the default start URL. ```APIDOC ## launch manifest_id, url=None ### Description Launches the installed web app, or a URL in the same web app instead of the default start URL if it is provided. Returns a page Target.TargetID which can be used to attach to via Target.attachToTarget or similar APIs. ### Method launch ### Parameters #### Path Parameters - **manifest_id** (str) - Required - The manifest ID of the PWA to launch. - **url** (Optional[str]) - Optional - The specific URL within the PWA to launch. ### Return Type Generator[Dict[str, Any], Dict[str, Any], Dict[str, Any], Tuple[int, List[FileHandler]]] ``` -------------------------------- ### Create Browser Instance Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/nodriver/classes/browser.md The entry point for creating a Browser instance. It asynchronously launches the browser process. ```python browser = await Browser.create(**kwargs) ``` -------------------------------- ### start_desktop_mirroring(sink_name) Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/nodriver/cdp/cast.html Initiates mirroring of the entire desktop to the specified cast sink. ```APIDOC ## start_desktop_mirroring(sink_name) ### Description Starts mirroring the desktop to the sink. ### Method Generator ### Parameters #### Query Parameters - **sink_name** (str) - Required - The name of the sink to mirror the desktop to. ### Return Type `Generator[Dict[str, Any], Dict[str, Any], None]` ``` -------------------------------- ### Get All-Time Sampling Profile Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/memory.html Retrieves the native memory allocations profile collected since the renderer process started. This provides a historical view of memory usage. ```python def get_all_time_sampling_profile() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,SamplingProfile]: ''' Retrieve native memory allocations profile collected since renderer process startup. :returns: ''' cmd_dict: T_JSON_DICT = { 'method': 'Memory.getAllTimeSamplingProfile', } json = yield cmd_dict return SamplingProfile.from_json(json['profile']) ``` -------------------------------- ### launch Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/markdown/nodriver/cdp/pwa.md Launches an installed PWA. Optionally, a specific URL within the PWA can be provided to launch instead of the default start URL. Returns the Target ID of the launched tab. ```APIDOC ## launch(manifest_id, url=None) ### Description Launches the installed web app. If a URL is provided, it launches that specific URL within the web app instead of the default start URL. ### Parameters #### Path Parameters - **manifest_id** (str) - Required - The manifest ID of the PWA to launch. - **url** (Optional[str]) - Optional - The specific URL within the web app to launch. ### Return type Generator[Dict[str, Any], Dict[str, Any], TargetID] ### Returns The Target ID of the tab created as a result of launching the PWA. ``` -------------------------------- ### Start Browser Process Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/nodriver/classes/browser.md Launches the actual browser executable. This method should be called after creating the Browser instance. ```python await browser.start() ``` -------------------------------- ### Get Manifest Icons Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/page.html Fetches the primary icon from a web page's manifest. Note: This method is deprecated as the returned icon is not guaranteed to be the one used for PWA installation. ```python cmd_dict: T_JSON_DICT = { 'method': 'Page.getManifestIcons', } json = yield cmd_dict return str(json['primaryIcon']) if json.get('primaryIcon', None) is not None else None ``` -------------------------------- ### Launch a PWA Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/pwa.html Launches an installed Progressive Web App. Optionally, a specific URL within the app can be provided to launch instead of the default start URL. Returns the Target.TargetID of the created page. ```python def launch(manifest_id: str, url: typing.Optional[str] = None) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, target.TargetID]: ''' Launches the installed web app, or an url in the same web app instead of the default start url if it is provided. Returns a page Target.TargetID which can be used to attach to via Target.attachToTarget or similar APIs. :param manifest_id: :param url: *(Optional)* :returns: ID of the tab target created as a result. ''' params: T_JSON_DICT = dict() params['manifestId'] = manifest_id if url is not None: params['url'] = url cmd_dict: T_JSON_DICT = { 'method': 'PWA.launch', 'params': params, } json = yield cmd_dict return target.TargetID.from_json(json['targetId']) ``` -------------------------------- ### cast.start_desktop_mirroring() Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/genindex.html Starts desktop mirroring for casting. This function is part of the cast module. ```APIDOC ## cast.start_desktop_mirroring() ### Description Starts desktop mirroring for casting. ### Method (Not specified, assumed to be a function call) ### Endpoint (Not applicable for SDK methods) ### Parameters (No parameters specified) ### Request Example ```python import nodriver.cdp.cast nodriver.cdp.cast.start_desktop_mirroring() ``` ### Response (No response details specified) ``` -------------------------------- ### Custom Browser Startup Options Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/README.md Configure browser startup with custom options such as headless mode, user data directory, browser executable path, arguments, and language settings. ```python from nodriver import * browser = await start( headless=False, user_data_dir="/path/to/existing/profile", # by specifying it, it won't be automatically cleaned up when finished browser_executable_path="/path/to/some/other/browser", browser_args=['--some-browser-arg=true', '--some-other-option'], lang="en-US" # this could set iso-language-code in navigator, not recommended to change ) tab = await browser.get('https://somewebsite.com') ``` -------------------------------- ### Get Browser Sampling Profile Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/memory.html Retrieves the native memory allocations profile collected since the browser process started. This offers a broader perspective on memory usage across the entire browser. ```python def get_browser_sampling_profile() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,SamplingProfile]: ''' Retrieve native memory allocations profile collected since browser process startup. :returns: ''' cmd_dict: T_JSON_DICT = { 'method': 'Memory.getBrowserSamplingProfile', } json = yield cmd_dict return SamplingProfile.from_json(json['profile']) ``` -------------------------------- ### Launch Browser Instance Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/core/browser.html Launches the actual browser instance. It handles connecting to an existing instance or starting a new one, including checks for the browser executable path and loading extensions. Use `await Browser.create()` to instantiate. ```python if not self: warnings.warn("use `await Browser.create()` to create a new instance") return if self._process or self._process_pid: if self._process.returncode is not None: return await self.create(config=self.config) warnings.warn("ignored! this call has no effect when already running.") return # self.config.update(kwargs) connect_existing = False if self.config.host is not None and self.config.port is not None: connect_existing = True else: self.config.host = "127.0.0.1" self.config.port = util.free_port() if not connect_existing: logger.debug( "BROWSER EXECUTABLE PATH: %s", self.config.browser_executable_path ) if not pathlib.Path(self.config.browser_executable_path).exists(): raise FileNotFoundError( ( """ --------------------- Could not determine browser executable. --------------------- Make sure your browser is installed in the default location (path). If you are sure about the browser executable, you can specify it using the `browser_executable_path='{}'` parameter.""" ).format( "/path/to/browser/executable" if is_posix else "c:/path/to/your/browser.exe" ) ) if getattr(self.config, "_extensions", None): # noqa self.config.add_argument( "--load-extension=%s" % ",".join(str(_) for _ in self.config._extensions) ) # noqa exe = self.config.browser_executable_path params = self.config() logger.info( ``` -------------------------------- ### DownloadWillBegin Event Class Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/page.html Fired when a page is about to start a download. This experimental event class, deprecated in favor of Browser.downloadWillBegin, provides the frame ID, download GUID, URL, and suggested filename for the download. ```python from typing import Dict from nodriver.cdp.page import FrameId from nodriver.cdp.cdp_types import T_JSON_DICT @deprecated(version="1.3") @event_class('Page.downloadWillBegin') @dataclass class DownloadWillBegin: ''' **EXPERIMENTAL** Fired when page is about to start a download. Deprecated. Use Browser.downloadWillBegin instead. ' #: Id of the frame that caused download to begin. frame_id: FrameId #: Global unique identifier of the download. guid: str #: URL of the resource being downloaded. url: str #: Suggested file name of the resource (the actual name of the file saved on disk may differ). suggested_filename: str @classmethod def from_json(cls, json: T_JSON_DICT) -> DownloadWillBegin: return cls( frame_id=FrameId.from_json(json['frameId']), guid=str(json['guid']), url=str(json['url']), suggested_filename=str(json['suggestedFilename']) ) ``` -------------------------------- ### enable Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/nodriver/cdp/bluetooth_emulation.html Enable the BluetoothEmulation domain with specified state and LE support. This prepares the system for Bluetooth emulation. ```APIDOC ## enable(_state_, _le_supported_) ### Description Enable the BluetoothEmulation domain. ### Parameters #### Path Parameters - **_state_** (CentralState) - Required - State of the simulated central. - **_le_supported_** (bool) - Required - If the simulated central supports low-energy. ### Method APICALL ### Endpoint bluetooth_emulation.enable ### Return Type Generator[Dict[str, Any], Dict[str, Any], None] ``` -------------------------------- ### Stop CSS Rule Usage Tracking Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/css.html Stops tracking CSS rule usage and returns a list of rules used since the last call to `takeCoverageDelta` or the start of instrumentation. Use this to get a snapshot of rule usage. ```python def stop_rule_usage_tracking() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[RuleUsage]]: ''' Stop tracking rule usage and return the list of rules that were used since last call to `takeCoverageDelta` (or since start of coverage instrumentation). :returns: ''' cmd_dict: T_JSON_DICT = { 'method': 'CSS.stopRuleUsageTracking', } json = yield cmd_dict return [RuleUsage.from_json(i) for i in json['ruleUsage']] ``` -------------------------------- ### install Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/nodriver/cdp/pwa.md Installs a PWA using its manifest ID and an optional installation URL or bundle URL. Supports IWA-specific and file/dev proxy installation modes. ```APIDOC ## install(manifest_id: str, install_url_or_bundle_url: str | None = None) ### Description Installs the given manifest identity, optionally using the given installUrlOrBundleUrl. This method supports IWA-specific, file installation, and dev proxy installation modes. ### Parameters * **manifest_id** (str) - The identifier for the PWA's manifest. * **install_url_or_bundle_url** (str | None, Optional) - The location of the app or bundle overriding the one derived from the manifestId. Can be a file:// URL, http(s):// URL for a signed web bundle, or http(s):// URL for a dev mode IWA. ### Returns A generator yielding installation progress and status. ``` -------------------------------- ### install Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/pwa.html Installs a PWA using its manifest ID, with an optional URL for the installable app or bundle. ```APIDOC ## install ### Description Installs the given manifest identity, optionally using the given installUrlOrBundleUrl. IWA-specific install description: manifestId corresponds to isolated-app:// + web_package::SignedWebBundleId File installation mode: The installUrlOrBundleUrl can be either file:// or http(s):// pointing to a signed web bundle (.swbn). In this case SignedWebBundleId must correspond to The .swbn file's signing key. Dev proxy installation mode: installUrlOrBundleUrl must be http(s):// that serves dev mode IWA. web_package::SignedWebBundleId must be of type dev proxy. The advantage of dev proxy mode is that all changes to IWA automatically will be reflected in the running app without reinstallation. To generate bundle id for proxy mode: 1. Generate 32 random bytes. 2. Add a specific suffix at the end following the documentation https://github.com/WICG/isolated-web-apps/blob/main/Scheme.md#suffix 3. Encode the entire sequence using Base32 without padding. If Chrome is not in IWA dev mode, the installation will fail, regardless of the state of the allowlist. ### Parameters #### Query Parameters - **manifest_id** (str) - Required - The manifest ID. - **install_url_or_bundle_url** (Optional[str]) - Optional - The location of the app or bundle overriding the one derived from the manifestId. ``` -------------------------------- ### Browser.start() Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/genindex.html Starts the browser instance. This is a method available on the Browser class. ```APIDOC ## Browser.start() ### Description Starts the browser instance. ### Method (Not specified, assumed to be a method call) ### Endpoint (Not applicable for SDK methods) ### Parameters (No parameters specified) ### Request Example ```python browser.start() ``` ### Response (No response details specified) ``` -------------------------------- ### Install PWA Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/pwa.html Installs a PWA using its manifest ID, optionally specifying an install URL or bundle URL. Supports IWA, file, and dev proxy installation modes. ```python def install( manifest_id: str, install_url_or_bundle_url: typing.Optional[str] = None ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]: ''' Installs the given manifest identity, optionally using the given installUrlOrBundleUrl IWA-specific install description: manifestId corresponds to isolated-app:// + web_package::SignedWebBundleId File installation mode: The installUrlOrBundleUrl can be either file:// or http(s):// pointing to a signed web bundle (.swbn). In this case SignedWebBundleId must correspond to The .swbn file's signing key. Dev proxy installation mode: installUrlOrBundleUrl must be http(s):// that serves dev mode IWA. web_package::SignedWebBundleId must be of type dev proxy. The advantage of dev proxy mode is that all changes to IWA automatically will be reflected in the running app without reinstallation. To generate bundle id for proxy mode: 1. Generate 32 random bytes. 2. Add a specific suffix at the end following the documentation https://github.com/WICG/isolated-web-apps/blob/main/Scheme.md#suffix 3. Encode the entire sequence using Base32 without padding. If Chrome is not in IWA dev mode, the installation will fail, regardless of the state of the allowlist. :param manifest_id: :param install_url_or_bundle_url: *(Optional)* The location of the app or bundle overriding the one derived from the manifestId. ''' params: T_JSON_DICT = dict() params['manifestId'] = manifest_id if install_url_or_bundle_url is not None: ``` -------------------------------- ### install Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_sources/nodriver/cdp/pwa.rst.txt Installs a PWA. ```APIDOC ## install ### Description Installs a PWA. ### Method (Not specified, assumed to be a function call in the SDK) ### Parameters (Parameters not explicitly detailed in the source, but would typically include PWA URL or manifest) ### Request Example (Example not provided in source) ### Response (Response details not provided in source) ``` -------------------------------- ### Start Screencast Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/page.html Initiates a screencast, sending frames to the client. Supports optional quality, max dimensions, and frame interval. ```python def start_screencast( format_: str = 'png', quality: int = -1, max_width: int = -1, max_height: int = -1, every_nth_frame: int = -1, ) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]: ''' Starts sending each frame in the page. ''' params: T_JSON_DICT = dict() if format_ is not None: params['format'] = format_ if quality is not None: params['quality'] = quality if max_width is not None: params['maxWidth'] = max_width if max_height is not None: params['maxHeight'] = max_height if every_nth_frame is not None: params['everyNthFrame'] = every_nth_frame cmd_dict: T_JSON_DICT = { 'method': 'Page.startScreencast', 'params': params, } json = yield cmd_dict ``` -------------------------------- ### Install PWA Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/nodriver/cdp/pwa.html Installs a Progressive Web App using its manifest ID. Optionally, an install URL or bundle URL can be provided to override the default. ```APIDOC ## install manifest_id, install_url_or_bundle_url=None ### Description Installs the given manifest identity, optionally using the given installUrlOrBundleUrl. This method supports IWA-specific installation and file installation modes. ### Method install ### Parameters #### Path Parameters - **manifest_id** (str) - Required - The id from the webapp’s manifest file. - **install_url_or_bundle_url** (Optional[str]) - Optional - The location of the app or bundle overriding the one derived from the manifestId. ### Return Type Generator[Dict[str, Any], Dict[str, Any], None] ``` -------------------------------- ### start_screencast Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/page.html Starts sending each frame in the screencast. Supports optional parameters for compression quality, maximum dimensions, and frame interval. ```APIDOC ## Page.startScreencast ### Description Starts sending each frame in the screencast. Supports optional parameters for compression quality, maximum dimensions, and frame interval. ### Method POST ### Endpoint /json/version ### Parameters #### Query Parameters - **format** (string) - Optional - The format of the screencast frames. - **quality** (integer) - Optional - Compression quality from range [0..100]. - **maxWidth** (integer) - Optional - Maximum screenshot width. - **maxHeight** (integer) - Optional - Maximum screenshot height. - **everyNthFrame** (integer) - Optional - Send every n-th frame. ### Request Example ```json { "method": "Page.startScreencast", "params": { "format": "png", "quality": 80, "maxWidth": 1024, "maxHeight": 768, "everyNthFrame": 2 } } ``` ### Response #### Success Response (200) - **result** (object) - An empty object if successful. #### Response Example ```json { "result": {} } ``` ``` -------------------------------- ### Install a PWA Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/pwa.html Installs a Progressive Web App using its installation URL or bundle URL. This function sends a 'PWA.install' command to the CDP client. ```python def install(install_url_or_bundle_url: str) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]: ''' Installs the PWA. :param install_url_or_bundle_url: ''' params: T_JSON_DICT = dict() params['installUrlOrBundleUrl'] = install_url_or_bundle_url cmd_dict: T_JSON_DICT = { 'method': 'PWA.install', 'params': params, } json = yield cmd_dict ``` -------------------------------- ### PWA.install Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/pwa.html Installs the PWA from the given install URL or bundle URL. ```APIDOC ## PWA.install ### Description Installs the PWA from the given install URL or bundle URL. ### Method POST ### Endpoint PWA.install ### Parameters #### Request Body - **installUrlOrBundleUrl** (string) - Required - The URL for the installation. ### Request Example { "installUrlOrBundleUrl": "http://example.com/install.zip" } ### Response #### Success Response (200) (No specific response fields documented) #### Response Example (No example provided) ``` -------------------------------- ### Opening a New Window Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_sources/index.rst.txt Demonstrates how to open a new browser window. ```python tab_win = await browser.get(url, new_window=True) ``` -------------------------------- ### Opening New Tabs and Windows Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_sources/readme.rst.txt Examples for opening a new tab or a new browser window to a specified URL. ```python tab = await browser.get(url, new_tab=True) ``` ```python tab_win = await browser.get(url, new_window=True) ``` -------------------------------- ### AnimationStarted Event Source: https://github.com/ultrafunkamsterdam/nodriver/blob/main/docs/_build/html/_modules/nodriver/cdp/animation.html Represents the event fired when an animation has started. It includes the animation object that was started. ```APIDOC ## AnimationStarted Event ### Description Event for animation that has been started. ### Event Details - **animation** (Animation) - Required - Animation that was started. ```