ChromeOptions

class selenium_driverless.types.options.Options[source]

the webdriver.ChromeOptions class

Warning

options should not be reused

use_extension: bool = True

don’t add the chrome-extension by default

Warning

setting proxies and auth while running requires the extension to be added. As an alternative, you might use --proxy-server=host:port and Requests-interception to provide auth

property arguments: List[str]

used arguments for the chrome executable

add_argument(argument)[source]

Adds an argument for launching chrome

Parameters:

argument (str) – argument to add

add_arguments(*arguments)[source]

add multiple arguments

Parameters:

arguments (str) – arguments to add

property prefs: dict

the preferences as json

update_pref(pref, value)[source]

update a preference

Parameters:
  • pref (str) – name of the preference (“.” dot path)

  • value – the value to set the preference to

property user_data_dir: str

the directory to save all browser data in. None (default) will temporarily create a directory in $temp

property downloads_dir

the default directory to download files to.

_dir = os.getcwd()+"/downloads"
if not os.path.isdir(_dir):
    os.mkdir(_dir)
options = webdriver.ChromeOptions()
options.downloads_dir = _dir
options.update_pref("plugins.always_open_pdf_externally", True)
async with webdriver.Chrome(options=options) as driver:
    download_data = await driver.get('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf', timeout=5)
    print(download_data.get("guid_file"))

Warning

path has to be absolute

property headless: bool

Whether chrome starts headless. defaults to False

property startup_url: str

the url the first tab loads. Defaults to about:blank

property binary_location: str

path to the Chromium binary

property env

the env for subprocess.Popen, ``os.environ by default

add_extension(path)[source]

Adds an extension to Chrome The extension can either be a compressed file (zip, crx, etc.) or extracted in a directory

Parameters:

path (str) – path to the extension

Return type:

None

property debugger_address: str

The address of the remote devtools instance in format “host:port” Setting this value makes the driver connect to a remote browser instance (unless you set user-data-dir as well)

property single_proxy

Set a single proxy to be applied.

options = webdriver.ChromeOptions()
options.single_proxy = "http://user1:passwrd1@example.proxy.com:5001/"

Warning

  • Only supported when Chrome has been started with driverless or the extension at selenium_driverless/files/mv3_extension has been loaded into the browser.

  • Socks5 doesn’t support authentication due to crbug#1309413.

property auto_clean_dirs: bool

if user-data-dir should be cleaned automatically defaults to True

enable_mobile(android_package='com.android.chrome', android_activity=None, device_serial=None)[source]

Enables mobile browser use for browsers that support it.

Parameters:
  • android_activity (Optional[str]) – The name of the android package to start

  • android_package (str) –

  • device_serial (Optional[str]) –

Return type:

None

Warning

Not Implemented yet

property accept_insecure_certs: bool
Returns:

whether the session accepts insecure certificates

Warning

NotImplemented yet

ignore_local_proxy_environment_variables()[source]

By calling this you will ignore HTTP_PROXY and HTTPS_PROXY from being picked up and used. :rtype: None

Warning

NotImplemented yet

add_experimental_option(name, value)[source]

Adds an experimental option which is passed to chromium.

Warning

only name="prefs" supported. This method is deprecated and will be removed. Use ChromeOptions.update_pref instead.

Parameters:
  • name (str) – The experimental option name.

  • value (Union[str, int, dict, List[str]]) – The option value.

Return type:

None