Get Virtual Sensor Information

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The Get Virtual Sensor Information command of the WebDriver API returns information about a virtual sensor previously created with the Create Virtual Sensor command. It reports the sampling frequency currently requested by the page, which lets a test confirm that the Sensor APIs are consuming readings at the expected rate.

Syntax

Method URI template
GET /session/{session id}/sensor/{type}

URL parameters

session id

Identifier of the session.

type

The virtual sensor type to query, for example "ambient-light".

Return value

An object with the following field:

requestedSamplingFrequency

A number giving the sampling frequency, in hertz, currently requested for the virtual sensor. This value is bounded by the minimum and maximum sampling frequencies that were set when the sensor was created.

Errors

invalid session id

Session does not exist.

invalid argument

No virtual sensor of the given type exists.

Examples

Getting virtual sensor information

With a WebDriver server running on localhost:4444, assume a virtual "ambient-light" sensor has been created for the active session. To read its information, append the sensor type to the endpoint, replacing ID with the sessionId from the New Session response:

bash
curl -i http://localhost:4444/session/ID/sensor/ambient-light

The server responds with the currently requested sampling frequency:

http
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8

{"value":{"requestedSamplingFrequency":60}}

Specifications

Specification
Generic Sensor API
# get-virtual-sensor-information-command

Browser compatibility

See also