Browser class#
Browser class#
- class Browser(config, **kwargs)[source]#
The Browser object is the “root” of the hierarchy and contains a reference to the browser parent process. there should usually be only 1 instance of this.
All opened tabs, extra browser screens and resources will not cause a new Browser process, but rather create additional
nodriver.Tabobjects.So, besides starting your instance and first/additional tabs, you don’t actively use it a lot under normal conditions.
- Tab objects will represent and control
tabs (as you know them)
browser windows (new window)
iframe
background processes
note: the Browser object is not instantiated by __init__ but using the asynchronous
nodriver.Browser.create()method.note: in Chromium based browsers, there is a parent process which keeps running all the time, even if there are no visible browser windows. sometimes it’s stubborn to close it, so make sure after using this library, the browser is correctly and fully closed/exited/killed.
- async classmethod create(config=None, *, user_data_dir=None, headless=False, browser_executable_path=None, browser_args=None, sandbox=True, host=None, port=None, **kwargs)[source]#
entry point for creating an instance
- Return type:
-
connection:
Connection#
- property websocket_url#
- property cookies: CookieJar#
- property stopped#
- async wait(time=0.1)[source]#
wait for <time> seconds. important to use, especially in between page navigation
- async sleep(time=0.1)#
alias for wait
- async get(url='chrome://welcome', new_tab=False, new_window=False)[source]#
top level get. utilizes the first tab to retrieve given url.
convenience function known from selenium. this function handles waits/sleeps and detects when DOM events fired, so it’s the safest way of navigating.
- async create_context(url='chrome://welcome', new_tab=False, new_window=True, dispose_on_detach=True, proxy_server=None, proxy_bypass_list=None, origins_with_universal_network_access=None)[source]#
creates a new browser context - mostly useful if you want to use proxies for different browser instances since chrome usually can only use 1 proxy per browser. socks5 with authentication is supported by using a forwarder proxy, the correct string to use socks proxy with username/password auth is socks://USERNAME:PASSWORD@SERVER:PORT
dispose_on_detach – (EXPERIMENTAL) (Optional) If specified, disposes this context when debugging session disconnects. proxy_server – (EXPERIMENTAL) (Optional) Proxy server, similar to the one passed to –proxy-server proxy_bypass_list – (EXPERIMENTAL) (Optional) Proxy bypass list, similar to the one passed to –proxy-bypass-list origins_with_universal_network_access – (EXPERIMENTAL) (Optional) An optional list of origins to grant unlimited cross-origin access to. Parts of the URL other than those constituting origin are ignored.
- async grant_all_permissions()[source]#
- grant permissions for:
accessibilityEvents audioCapture backgroundSync backgroundFetch clipboardReadWrite clipboardSanitizedWrite displayCapture durableStorage geolocation idleDetection localFonts midi midiSysex nfc notifications paymentHandler periodicBackgroundSync protectedMediaIdentifier sensors storageAccess topLevelStorageAccess videoCapture videoCapturePanTiltZoom wakeLockScreen wakeLockSystem windowManagement