Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# DOMStorage

Query and modify DOM storage.

This CDP domain is experimental.

- Types

- Commands

- Events

## 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 SerializedStorageKey

class StorageId(is_local_storage, security_origin=None, storage_key=None)

  DOM Storage identifier.

  is_local_storage: `bool`

    Whether the storage is local storage (not session storage).

  security_origin: `Optional`[`str`] = None

    Security origin for the storage.

  storage_key: `Optional`[`SerializedStorageKey`] = None

    Represents a key by which DOM Storage keys its CachedStorageAreas

class Item(iterable=(), /)

  DOM Storage item.

## 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.

clear(storage_id)
  Parameters:

    storage_id (`StorageId`) –

  Return type:

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

disable()

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

  Return type:

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

enable()

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

  Return type:

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

get_dom_storage_items(storage_id)
  Parameters:

    storage_id (`StorageId`) –

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `List`[`Item`]]

  Returns:

remove_dom_storage_item(storage_id, key)
  Parameters:

    - storage_id (`StorageId`) –

    - key (`str`) –

  Return type:

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

set_dom_storage_item(storage_id, key, value)
  Parameters:

    - storage_id (`StorageId`) –

    - key (`str`) –

    - value (`str`) –

  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 DomStorageItemAdded(storage_id, key, new_value)
  storage_id: `StorageId`
  key: `str`
  new_value: `str`

class DomStorageItemRemoved(storage_id, key)
  storage_id: `StorageId`
  key: `str`

class DomStorageItemUpdated(storage_id, key, old_value, new_value)
  storage_id: `StorageId`
  key: `str`
  old_value: `str`
  new_value: `str`

class DomStorageItemsCleared(storage_id)
  storage_id: `StorageId`