Skip to content

dom_storage

DomStorageItemAdded dataclass

Source code in zendriver/cdp/dom_storage.py
@event_class("DOMStorage.domStorageItemAdded")
@dataclass
class DomStorageItemAdded:
    storage_id: StorageId
    key: str
    new_value: str

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> DomStorageItemAdded:
        return cls(
            storage_id=StorageId.from_json(json["storageId"]),
            key=str(json["key"]),
            new_value=str(json["newValue"]),
        )

key: str instance-attribute

new_value: str instance-attribute

storage_id: StorageId instance-attribute

__init__(storage_id, key, new_value)

from_json(json) classmethod

Source code in zendriver/cdp/dom_storage.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> DomStorageItemAdded:
    return cls(
        storage_id=StorageId.from_json(json["storageId"]),
        key=str(json["key"]),
        new_value=str(json["newValue"]),
    )

DomStorageItemRemoved dataclass

Source code in zendriver/cdp/dom_storage.py
@event_class("DOMStorage.domStorageItemRemoved")
@dataclass
class DomStorageItemRemoved:
    storage_id: StorageId
    key: str

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> DomStorageItemRemoved:
        return cls(
            storage_id=StorageId.from_json(json["storageId"]), key=str(json["key"])
        )

key: str instance-attribute

storage_id: StorageId instance-attribute

__init__(storage_id, key)

from_json(json) classmethod

Source code in zendriver/cdp/dom_storage.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> DomStorageItemRemoved:
    return cls(
        storage_id=StorageId.from_json(json["storageId"]), key=str(json["key"])
    )

DomStorageItemUpdated dataclass

Source code in zendriver/cdp/dom_storage.py
@event_class("DOMStorage.domStorageItemUpdated")
@dataclass
class DomStorageItemUpdated:
    storage_id: StorageId
    key: str
    old_value: str
    new_value: str

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> DomStorageItemUpdated:
        return cls(
            storage_id=StorageId.from_json(json["storageId"]),
            key=str(json["key"]),
            old_value=str(json["oldValue"]),
            new_value=str(json["newValue"]),
        )

key: str instance-attribute

new_value: str instance-attribute

old_value: str instance-attribute

storage_id: StorageId instance-attribute

__init__(storage_id, key, old_value, new_value)

from_json(json) classmethod

Source code in zendriver/cdp/dom_storage.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> DomStorageItemUpdated:
    return cls(
        storage_id=StorageId.from_json(json["storageId"]),
        key=str(json["key"]),
        old_value=str(json["oldValue"]),
        new_value=str(json["newValue"]),
    )

DomStorageItemsCleared dataclass

Source code in zendriver/cdp/dom_storage.py
@event_class("DOMStorage.domStorageItemsCleared")
@dataclass
class DomStorageItemsCleared:
    storage_id: StorageId

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> DomStorageItemsCleared:
        return cls(storage_id=StorageId.from_json(json["storageId"]))

storage_id: StorageId instance-attribute

__init__(storage_id)

from_json(json) classmethod

Source code in zendriver/cdp/dom_storage.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> DomStorageItemsCleared:
    return cls(storage_id=StorageId.from_json(json["storageId"]))

Item

Bases: list

DOM Storage item.

Source code in zendriver/cdp/dom_storage.py
class Item(list):
    """
    DOM Storage item.
    """

    def to_json(self) -> typing.List[str]:
        return self

    @classmethod
    def from_json(cls, json: typing.List[str]) -> Item:
        return cls(json)

    def __repr__(self):
        return "Item({})".format(super().__repr__())

__repr__()

Source code in zendriver/cdp/dom_storage.py
def __repr__(self):
    return "Item({})".format(super().__repr__())

from_json(json) classmethod

Source code in zendriver/cdp/dom_storage.py
@classmethod
def from_json(cls, json: typing.List[str]) -> Item:
    return cls(json)

to_json()

Source code in zendriver/cdp/dom_storage.py
def to_json(self) -> typing.List[str]:
    return self

SerializedStorageKey

Bases: str

Source code in zendriver/cdp/dom_storage.py
class SerializedStorageKey(str):
    def to_json(self) -> str:
        return self

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

    def __repr__(self):
        return "SerializedStorageKey({})".format(super().__repr__())

__repr__()

Source code in zendriver/cdp/dom_storage.py
def __repr__(self):
    return "SerializedStorageKey({})".format(super().__repr__())

from_json(json) classmethod

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

to_json()

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

StorageId dataclass

DOM Storage identifier.

Source code in zendriver/cdp/dom_storage.py
@dataclass
class StorageId:
    """
    DOM Storage identifier.
    """

    #: Whether the storage is local storage (not session storage).
    is_local_storage: bool

    #: Security origin for the storage.
    security_origin: typing.Optional[str] = None

    #: Represents a key by which DOM Storage keys its CachedStorageAreas
    storage_key: typing.Optional[SerializedStorageKey] = None

    def to_json(self) -> T_JSON_DICT:
        json: T_JSON_DICT = dict()
        json["isLocalStorage"] = self.is_local_storage
        if self.security_origin is not None:
            json["securityOrigin"] = self.security_origin
        if self.storage_key is not None:
            json["storageKey"] = self.storage_key.to_json()
        return json

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> StorageId:
        return cls(
            is_local_storage=bool(json["isLocalStorage"]),
            security_origin=(
                str(json["securityOrigin"])
                if json.get("securityOrigin", None) is not None
                else None
            ),
            storage_key=(
                SerializedStorageKey.from_json(json["storageKey"])
                if json.get("storageKey", None) is not None
                else None
            ),
        )

is_local_storage: bool instance-attribute

security_origin: typing.Optional[str] = None class-attribute instance-attribute

storage_key: typing.Optional[SerializedStorageKey] = None class-attribute instance-attribute

__init__(is_local_storage, security_origin=None, storage_key=None)

from_json(json) classmethod

Source code in zendriver/cdp/dom_storage.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> StorageId:
    return cls(
        is_local_storage=bool(json["isLocalStorage"]),
        security_origin=(
            str(json["securityOrigin"])
            if json.get("securityOrigin", None) is not None
            else None
        ),
        storage_key=(
            SerializedStorageKey.from_json(json["storageKey"])
            if json.get("storageKey", None) is not None
            else None
        ),
    )

to_json()

Source code in zendriver/cdp/dom_storage.py
def to_json(self) -> T_JSON_DICT:
    json: T_JSON_DICT = dict()
    json["isLocalStorage"] = self.is_local_storage
    if self.security_origin is not None:
        json["securityOrigin"] = self.security_origin
    if self.storage_key is not None:
        json["storageKey"] = self.storage_key.to_json()
    return json

clear(storage_id)

Parameters:

Name Type Description Default
storage_id StorageId
required
Source code in zendriver/cdp/dom_storage.py
def clear(storage_id: StorageId) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    :param storage_id:
    """
    params: T_JSON_DICT = dict()
    params["storageId"] = storage_id.to_json()
    cmd_dict: T_JSON_DICT = {
        "method": "DOMStorage.clear",
        "params": params,
    }
    json = yield cmd_dict

disable()

Disables storage tracking, prevents storage events from being sent to the client.

Source code in zendriver/cdp/dom_storage.py
def disable() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Disables storage tracking, prevents storage events from being sent to the client.
    """
    cmd_dict: T_JSON_DICT = {
        "method": "DOMStorage.disable",
    }
    json = yield cmd_dict

enable()

Enables storage tracking, storage events will now be delivered to the client.

Source code in zendriver/cdp/dom_storage.py
def enable() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Enables storage tracking, storage events will now be delivered to the client.
    """
    cmd_dict: T_JSON_DICT = {
        "method": "DOMStorage.enable",
    }
    json = yield cmd_dict

get_dom_storage_items(storage_id)

Parameters:

Name Type Description Default
storage_id StorageId
required

Returns:

Type Description
Generator[T_JSON_DICT, T_JSON_DICT, List[Item]]
Source code in zendriver/cdp/dom_storage.py
def get_dom_storage_items(
    storage_id: StorageId,
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, typing.List[Item]]:
    """
    :param storage_id:
    :returns:
    """
    params: T_JSON_DICT = dict()
    params["storageId"] = storage_id.to_json()
    cmd_dict: T_JSON_DICT = {
        "method": "DOMStorage.getDOMStorageItems",
        "params": params,
    }
    json = yield cmd_dict
    return [Item.from_json(i) for i in json["entries"]]

remove_dom_storage_item(storage_id, key)

Parameters:

Name Type Description Default
storage_id StorageId
required
key str
required
Source code in zendriver/cdp/dom_storage.py
def remove_dom_storage_item(
    storage_id: StorageId, key: str
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    :param storage_id:
    :param key:
    """
    params: T_JSON_DICT = dict()
    params["storageId"] = storage_id.to_json()
    params["key"] = key
    cmd_dict: T_JSON_DICT = {
        "method": "DOMStorage.removeDOMStorageItem",
        "params": params,
    }
    json = yield cmd_dict

set_dom_storage_item(storage_id, key, value)

Parameters:

Name Type Description Default
storage_id StorageId
required
key str
required
value str
required
Source code in zendriver/cdp/dom_storage.py
def set_dom_storage_item(
    storage_id: StorageId, key: str, value: str
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    :param storage_id:
    :param key:
    :param value:
    """
    params: T_JSON_DICT = dict()
    params["storageId"] = storage_id.to_json()
    params["key"] = key
    params["value"] = value
    cmd_dict: T_JSON_DICT = {
        "method": "DOMStorage.setDOMStorageItem",
        "params": params,
    }
    json = yield cmd_dict