Skip to content

autofill

Address dataclass

Source code in zendriver/cdp/autofill.py
@dataclass
class Address:
    #: fields and values defining an address.
    fields: typing.List[AddressField]

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["fields"] = [i.to_json() for i in self.fields]
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> Address:
        return cls(
            fields=[AddressField.from_json(i) for i in json["fields"]],
        )

fields: typing.List[AddressField] instance-attribute

__init__(fields)

from_json(json) classmethod

Source code in zendriver/cdp/autofill.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> Address:
    return cls(
        fields=[AddressField.from_json(i) for i in json["fields"]],
    )

to_json()

Source code in zendriver/cdp/autofill.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["fields"] = [i.to_json() for i in self.fields]
    return json

AddressField dataclass

Source code in zendriver/cdp/autofill.py
@dataclass
class AddressField:
    #: address field name, for example GIVEN_NAME.
    name: str

    #: address field value, for example Jon Doe.
    value: str

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["name"] = self.name
        json["value"] = self.value
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> AddressField:
        return cls(
            name=str(json["name"]),
            value=str(json["value"]),
        )

name: str instance-attribute

value: str instance-attribute

__init__(name, value)

from_json(json) classmethod

Source code in zendriver/cdp/autofill.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AddressField:
    return cls(
        name=str(json["name"]),
        value=str(json["value"]),
    )

to_json()

Source code in zendriver/cdp/autofill.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["name"] = self.name
    json["value"] = self.value
    return json

AddressFields dataclass

A list of address fields.

Source code in zendriver/cdp/autofill.py
@dataclass
class AddressFields:
    """
    A list of address fields.
    """

    fields: typing.List[AddressField]

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["fields"] = [i.to_json() for i in self.fields]
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> AddressFields:
        return cls(
            fields=[AddressField.from_json(i) for i in json["fields"]],
        )

fields: typing.List[AddressField] instance-attribute

__init__(fields)

from_json(json) classmethod

Source code in zendriver/cdp/autofill.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AddressFields:
    return cls(
        fields=[AddressField.from_json(i) for i in json["fields"]],
    )

to_json()

Source code in zendriver/cdp/autofill.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["fields"] = [i.to_json() for i in self.fields]
    return json

AddressFormFilled dataclass

Emitted when an address form is filled.

Source code in zendriver/cdp/autofill.py
@event_class("Autofill.addressFormFilled")
@dataclass
class AddressFormFilled:
    """
    Emitted when an address form is filled.
    """

    #: Information about the fields that were filled
    filled_fields: typing.List[FilledField]
    #: An UI representation of the address used to fill the form.
    #: Consists of a 2D array where each child represents an address/profile line.
    address_ui: AddressUI

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> AddressFormFilled:
        return cls(
            filled_fields=[FilledField.from_json(i) for i in json["filledFields"]],
            address_ui=AddressUI.from_json(json["addressUi"]),
        )

address_ui: AddressUI instance-attribute

filled_fields: typing.List[FilledField] instance-attribute

__init__(filled_fields, address_ui)

from_json(json) classmethod

Source code in zendriver/cdp/autofill.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AddressFormFilled:
    return cls(
        filled_fields=[FilledField.from_json(i) for i in json["filledFields"]],
        address_ui=AddressUI.from_json(json["addressUi"]),
    )

AddressUI dataclass

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

Source code in zendriver/cdp/autofill.py
@dataclass
class AddressUI:
    """
    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
    """

    #: A two dimension array containing the representation of values from an address profile.
    address_fields: typing.List[AddressFields]

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["addressFields"] = [i.to_json() for i in self.address_fields]
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> AddressUI:
        return cls(
            address_fields=[AddressFields.from_json(i) for i in json["addressFields"]],
        )

address_fields: typing.List[AddressFields] instance-attribute

__init__(address_fields)

from_json(json) classmethod

Source code in zendriver/cdp/autofill.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AddressUI:
    return cls(
        address_fields=[AddressFields.from_json(i) for i in json["addressFields"]],
    )

to_json()

Source code in zendriver/cdp/autofill.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["addressFields"] = [i.to_json() for i in self.address_fields]
    return json

CreditCard dataclass

Source code in zendriver/cdp/autofill.py
@dataclass
class CreditCard:
    #: 16-digit credit card number.
    number: str

    #: Name of the credit card owner.
    name: str

    #: 2-digit expiry month.
    expiry_month: str

    #: 4-digit expiry year.
    expiry_year: str

    #: 3-digit card verification code.
    cvc: str

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["number"] = self.number
        json["name"] = self.name
        json["expiryMonth"] = self.expiry_month
        json["expiryYear"] = self.expiry_year
        json["cvc"] = self.cvc
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> CreditCard:
        return cls(
            number=str(json["number"]),
            name=str(json["name"]),
            expiry_month=str(json["expiryMonth"]),
            expiry_year=str(json["expiryYear"]),
            cvc=str(json["cvc"]),
        )

cvc: str instance-attribute

expiry_month: str instance-attribute

expiry_year: str instance-attribute

name: str instance-attribute

number: str instance-attribute

__init__(number, name, expiry_month, expiry_year, cvc)

from_json(json) classmethod

Source code in zendriver/cdp/autofill.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> CreditCard:
    return cls(
        number=str(json["number"]),
        name=str(json["name"]),
        expiry_month=str(json["expiryMonth"]),
        expiry_year=str(json["expiryYear"]),
        cvc=str(json["cvc"]),
    )

to_json()

Source code in zendriver/cdp/autofill.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["number"] = self.number
    json["name"] = self.name
    json["expiryMonth"] = self.expiry_month
    json["expiryYear"] = self.expiry_year
    json["cvc"] = self.cvc
    return json

FilledField dataclass

Source code in zendriver/cdp/autofill.py
@dataclass
class FilledField:
    #: The type of the field, e.g text, password etc.
    html_type: str

    #: the html id
    id_: str

    #: the html name
    name: str

    #: the field value
    value: str

    #: The actual field type, e.g FAMILY_NAME
    autofill_type: str

    #: The filling strategy
    filling_strategy: FillingStrategy

    #: The frame the field belongs to
    frame_id: page.FrameId

    #: The form field's DOM node
    field_id: dom.BackendNodeId

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["htmlType"] = self.html_type
        json["id"] = self.id_
        json["name"] = self.name
        json["value"] = self.value
        json["autofillType"] = self.autofill_type
        json["fillingStrategy"] = self.filling_strategy.to_json()
        json["frameId"] = self.frame_id.to_json()
        json["fieldId"] = self.field_id.to_json()
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> FilledField:
        return cls(
            html_type=str(json["htmlType"]),
            id_=str(json["id"]),
            name=str(json["name"]),
            value=str(json["value"]),
            autofill_type=str(json["autofillType"]),
            filling_strategy=FillingStrategy.from_json(json["fillingStrategy"]),
            frame_id=page.FrameId.from_json(json["frameId"]),
            field_id=dom.BackendNodeId.from_json(json["fieldId"]),
        )

autofill_type: str instance-attribute

field_id: dom.BackendNodeId instance-attribute

filling_strategy: FillingStrategy instance-attribute

frame_id: page.FrameId instance-attribute

html_type: str instance-attribute

id_: str instance-attribute

name: str instance-attribute

value: str instance-attribute

__init__(html_type, id_, name, value, autofill_type, filling_strategy, frame_id, field_id)

from_json(json) classmethod

Source code in zendriver/cdp/autofill.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> FilledField:
    return cls(
        html_type=str(json["htmlType"]),
        id_=str(json["id"]),
        name=str(json["name"]),
        value=str(json["value"]),
        autofill_type=str(json["autofillType"]),
        filling_strategy=FillingStrategy.from_json(json["fillingStrategy"]),
        frame_id=page.FrameId.from_json(json["frameId"]),
        field_id=dom.BackendNodeId.from_json(json["fieldId"]),
    )

to_json()

Source code in zendriver/cdp/autofill.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["htmlType"] = self.html_type
    json["id"] = self.id_
    json["name"] = self.name
    json["value"] = self.value
    json["autofillType"] = self.autofill_type
    json["fillingStrategy"] = self.filling_strategy.to_json()
    json["frameId"] = self.frame_id.to_json()
    json["fieldId"] = self.field_id.to_json()
    return json

FillingStrategy

Bases: Enum

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

Source code in zendriver/cdp/autofill.py
class FillingStrategy(enum.Enum):
    """
    Specified whether a filled field was done so by using the html autocomplete attribute or autofill heuristics.
    """

    AUTOCOMPLETE_ATTRIBUTE = "autocompleteAttribute"
    AUTOFILL_INFERRED = "autofillInferred"

    def to_json(self) -> str:
        return self.value

    @classmethod
    def from_json(cls, json: str) -> FillingStrategy:
        return cls(json)

AUTOCOMPLETE_ATTRIBUTE = 'autocompleteAttribute' class-attribute instance-attribute

AUTOFILL_INFERRED = 'autofillInferred' class-attribute instance-attribute

from_json(json) classmethod

Source code in zendriver/cdp/autofill.py
@classmethod
def from_json(cls, json: str) -> FillingStrategy:
    return cls(json)

to_json()

Source code in zendriver/cdp/autofill.py
def to_json(self) -> str:
    return self.value

disable()

Disables autofill domain notifications.

Source code in zendriver/cdp/autofill.py
def disable() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Disables autofill domain notifications.
    """
    cmd_dict: T_JSON_DICT = {
        "method": "Autofill.disable",
    }
    json = yield cmd_dict

enable()

Enables autofill domain notifications.

Source code in zendriver/cdp/autofill.py
def enable() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Enables autofill domain notifications.
    """
    cmd_dict: T_JSON_DICT = {
        "method": "Autofill.enable",
    }
    json = yield cmd_dict

set_addresses(addresses)

Set addresses so that developers can verify their forms implementation.

Parameters:

Name Type Description Default
addresses List[Address]
required
Source code in zendriver/cdp/autofill.py
def set_addresses(
    addresses: typing.List[Address],
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Set addresses so that developers can verify their forms implementation.

    :param addresses:
    """
    params: T_JSON_DICT = dict()
    params["addresses"] = [i.to_json() for i in addresses]
    cmd_dict: T_JSON_DICT = {
        "method": "Autofill.setAddresses",
        "params": params,
    }
    json = yield cmd_dict

trigger(field_id, card, frame_id=None)

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

Parameters:

Name Type Description Default
field_id BackendNodeId

Identifies a field that serves as an anchor for autofill.

required
frame_id Optional[FrameId]

(Optional) Identifies the frame that field belongs to.

None
card CreditCard

Credit card information to fill out the form. Credit card data is not saved.

required
Source code in zendriver/cdp/autofill.py
def trigger(
    field_id: dom.BackendNodeId,
    card: CreditCard,
    frame_id: typing.Optional[page.FrameId] = None,
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Trigger autofill on a form identified by the fieldId.
    If the field and related form cannot be autofilled, returns an error.

    :param field_id: Identifies a field that serves as an anchor for autofill.
    :param frame_id: *(Optional)* Identifies the frame that field belongs to.
    :param card: Credit card information to fill out the form. Credit card data is not saved.
    """
    params: T_JSON_DICT = dict()
    params["fieldId"] = field_id.to_json()
    if frame_id is not None:
        params["frameId"] = frame_id.to_json()
    params["card"] = card.to_json()
    cmd_dict: T_JSON_DICT = {
        "method": "Autofill.trigger",
        "params": params,
    }
    json = yield cmd_dict