Autofill#

Defines commands and events for Autofill.

This CDP domain is experimental.

Types#

Generally, you do not need to instantiate CDP types yourself. Instead, the API creates objects for you as return values from commands, and then you can use those objects as arguments to other commands.

class CreditCard(number, name, expiry_month, expiry_year, cvc)[source]#
number: str#

16-digit credit card number.

name: str#

Name of the credit card owner.

expiry_month: str#

2-digit expiry month.

expiry_year: str#

4-digit expiry year.

cvc: str#

3-digit card verification code.

class AddressField(name, value)[source]#
name: str#

address field name, for example GIVEN_NAME. The full list of supported field names: https://source.chromium.org/chromium/chromium/src/+/main:components/autofill/core/browser/field_types.cc;l=38

value: str#

address field value, for example Jon Doe.

class AddressFields(fields)[source]#

A list of address fields.

fields: List[AddressField]#
class Address(fields)[source]#
fields: List[AddressField]#

fields and values defining an address.

class AddressUI(address_fields)[source]#

Defines how an address can be displayed like in chrome://settings/addresses. Address UI is a two dimensional array, each inner array is an “address information line”, and when rendered in a UI surface should be displayed as such. The following address UI for instance: [[{name: “GIVE_NAME”, value: “Jon”}, {name: “FAMILY_NAME”, value: “Doe”}], [{name: “CITY”, value: “Munich”}, {name: “ZIP”, value: “81456”}]] should allow the receiver to render: Jon Doe Munich 81456

address_fields: List[AddressFields]#

A two dimension array containing the representation of values from an address profile.

class FillingStrategy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Specified whether a filled field was done so by using the html autocomplete attribute or autofill heuristics.

AUTOCOMPLETE_ATTRIBUTE = 'autocompleteAttribute'#
AUTOFILL_INFERRED = 'autofillInferred'#
class FilledField(html_type, id_, name, value, autofill_type, filling_strategy, frame_id, field_id)[source]#
html_type: str#

The type of the field, e.g text, password etc.

id_: str#

the html id

name: str#

the html name

value: str#

the field value

autofill_type: str#

The actual field type, e.g FAMILY_NAME

filling_strategy: FillingStrategy#

The filling strategy

frame_id: FrameId#

The frame the field belongs to

field_id: BackendNodeId#

The form field’s DOM node

Commands#

Each command is a generator function. The return type Generator[x, y, z] indicates that the generator yields arguments of type x, it must be resumed with an argument of type y, and it returns type z. In this library, types x and y are the same for all commands, and z is the return type you should pay attention to. For more information, see Getting Started: Commands.

disable()[source]#

Disables autofill domain notifications.

Return type:

Generator[Dict[str, Any], Dict[str, Any], None]

enable()[source]#

Enables autofill domain notifications.

Return type:

Generator[Dict[str, Any], Dict[str, Any], None]

set_addresses(addresses)[source]#

Set addresses so that developers can verify their forms implementation.

Parameters:

addresses (List[Address]) –

Return type:

Generator[Dict[str, Any], Dict[str, Any], None]

trigger(field_id, frame_id=None, card=None, address=None)[source]#

Trigger autofill on a form identified by the fieldId. If the field and related form cannot be autofilled, returns an error.

Parameters:
  • field_id (BackendNodeId) – Identifies a field that serves as an anchor for autofill.

  • frame_id (Optional[FrameId]) – (Optional) Identifies the frame that field belongs to.

  • card (Optional[CreditCard]) – (Optional) Credit card information to fill out the form. Credit card data is not saved. Mutually exclusive with `address``.

  • address (Optional[Address]) – (Optional) Address to fill out the form. Address data is not saved. Mutually exclusive with ``card`.

Return type:

Generator[Dict[str, Any], Dict[str, Any], None]

Events#

Generally, you do not need to instantiate CDP events yourself. Instead, the API creates events for you and then you use the event’s attributes.

class AddressFormFilled(filled_fields, address_ui)[source]#

Emitted when an address form is filled.

filled_fields: List[FilledField]#

Information about the fields that were filled

address_ui: AddressUI#

An UI representation of the address used to fill the form. Consists of a 2D array where each child represents an address/profile line.