Skip to content

device_access

DeviceId

Bases: str

A device id.

Source code in zendriver/cdp/device_access.py
class DeviceId(str):
    """
    A device id.
    """

    def to_json(self) -> str:
        return self

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

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

__repr__()

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

from_json(json) classmethod

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

to_json()

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

DeviceRequestPrompted dataclass

A device request opened a user prompt to select a device. Respond with the selectPrompt or cancelPrompt command.

Source code in zendriver/cdp/device_access.py
@event_class("DeviceAccess.deviceRequestPrompted")
@dataclass
class DeviceRequestPrompted:
    """
    A device request opened a user prompt to select a device. Respond with the
    selectPrompt or cancelPrompt command.
    """

    id_: RequestId
    devices: typing.List[PromptDevice]

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> DeviceRequestPrompted:
        return cls(
            id_=RequestId.from_json(json["id"]),
            devices=[PromptDevice.from_json(i) for i in json["devices"]],
        )

devices: typing.List[PromptDevice] instance-attribute

id_: RequestId instance-attribute

__init__(id_, devices)

from_json(json) classmethod

Source code in zendriver/cdp/device_access.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> DeviceRequestPrompted:
    return cls(
        id_=RequestId.from_json(json["id"]),
        devices=[PromptDevice.from_json(i) for i in json["devices"]],
    )

PromptDevice dataclass

Device information displayed in a user prompt to select a device.

Source code in zendriver/cdp/device_access.py
@dataclass
class PromptDevice:
    """
    Device information displayed in a user prompt to select a device.
    """

    id_: DeviceId

    #: Display name as it appears in a device request user prompt.
    name: str

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

    @classmethod
    def from_json(cls, json: T_JSON_DICT) -> PromptDevice:
        return cls(
            id_=DeviceId.from_json(json["id"]),
            name=str(json["name"]),
        )

id_: DeviceId instance-attribute

name: str instance-attribute

__init__(id_, name)

from_json(json) classmethod

Source code in zendriver/cdp/device_access.py
@classmethod
def from_json(cls, json: T_JSON_DICT) -> PromptDevice:
    return cls(
        id_=DeviceId.from_json(json["id"]),
        name=str(json["name"]),
    )

to_json()

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

RequestId

Bases: str

Device request id.

Source code in zendriver/cdp/device_access.py
class RequestId(str):
    """
    Device request id.
    """

    def to_json(self) -> str:
        return self

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

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

__repr__()

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

from_json(json) classmethod

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

to_json()

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

cancel_prompt(id_)

Cancel a prompt in response to a DeviceAccess.deviceRequestPrompted event.

Parameters:

Name Type Description Default
id_ RequestId
required
Source code in zendriver/cdp/device_access.py
def cancel_prompt(id_: RequestId) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Cancel a prompt in response to a DeviceAccess.deviceRequestPrompted event.

    :param id_:
    """
    params: T_JSON_DICT = dict()
    params["id"] = id_.to_json()
    cmd_dict: T_JSON_DICT = {
        "method": "DeviceAccess.cancelPrompt",
        "params": params,
    }
    json = yield cmd_dict

disable()

Disable events in this domain.

Source code in zendriver/cdp/device_access.py
def disable() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Disable events in this domain.
    """
    cmd_dict: T_JSON_DICT = {
        "method": "DeviceAccess.disable",
    }
    json = yield cmd_dict

enable()

Enable events in this domain.

Source code in zendriver/cdp/device_access.py
def enable() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Enable events in this domain.
    """
    cmd_dict: T_JSON_DICT = {
        "method": "DeviceAccess.enable",
    }
    json = yield cmd_dict

select_prompt(id_, device_id)

Select a device in response to a DeviceAccess.deviceRequestPrompted event.

Parameters:

Name Type Description Default
id_ RequestId
required
device_id DeviceId
required
Source code in zendriver/cdp/device_access.py
def select_prompt(
    id_: RequestId, device_id: DeviceId
) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:
    """
    Select a device in response to a DeviceAccess.deviceRequestPrompted event.

    :param id_:
    :param device_id:
    """
    params: T_JSON_DICT = dict()
    params["id"] = id_.to_json()
    params["deviceId"] = device_id.to_json()
    cmd_dict: T_JSON_DICT = {
        "method": "DeviceAccess.selectPrompt",
        "params": params,
    }
    json = yield cmd_dict