The Get Virtual Sensor Information command of the WebDriver API returns information about a virtual sensor previously created using 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.
| Method | URI template |
|---|---|
GET | /session/{session id}/sensor/{type} |
session idIdentifier of the session.
typeThe virtual sensor type to query. Possible values include "ambient-light", "accelerometer", and "gyroscope".
An object with the following field:
requestedSamplingFrequencyA number, in hertz, providing the sampling frequency 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.
invalid session idSession does not exist.
invalid argumentNo virtual sensor of the given type exists.
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:
curl -i http://localhost:4444/session/ID/sensor/ambient-lightThe server responds with the currently requested sampling frequency:
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
{"value":{"requestedSamplingFrequency":60}}