Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: Create Virtual Pressure Source
short-title: Create Virtual Pressure Source
slug: Web/WebDriver/Reference/Classic/Commands/CreateVirtualPressureSource
page-type: webdriver-command
browser-compat: webdriver.classic.CreateVirtualPressureSource
sidebar: webdriver
---

The _Create Virtual Pressure Source_ [command](/en-US/docs/Web/WebDriver/Reference/Classic/Commands) of the [WebDriver](/en-US/docs/Web/WebDriver) API creates a virtual pressure source of a given type that overrides the platform pressure source of the same type. This lets tests exercise the [Compute Pressure API](/en-US/docs/Web/API/Compute_Pressure_API) with predetermined pressure states instead of relying on real hardware.

## Syntax

| Method | URI template |
| ----------------------------------------------------- | -------------------------------------- |
| [`POST`](/en-US/docs/Web/HTTP/Reference/Methods/POST) | `/session/{session id}/pressuresource` |

### URL parameters

- `session id`
- : Identifier of the session.

### Payload

The input is an object:

- `type`
- : A string identifying the pressure source type to create. Currently the only widely supported value is `"cpu"`.
- `supported` {{optional_inline}}
- : A boolean indicating whether the virtual pressure source is able to provide samples. Defaults to `true`.

### Return value

`null` if successful.

### Errors

- [`invalid session id`](/en-US/docs/Web/WebDriver/Reference/Errors/InvalidSessionID)
- : Session does not exist.
- [`invalid argument`](/en-US/docs/Web/WebDriver/Reference/Errors/InvalidArgument)
- : The `type` is not a supported pressure source type, or a virtual pressure source of that type already exists.

## Examples

### Creating a virtual pressure source

With a WebDriver server running on `localhost:4444`, assume an active session has been created. To create a virtual `"cpu"` pressure source, send its type as the request payload, replacing `ID` with the `sessionId` from the [New Session](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/NewSession) response:

```bash
curl -i -H "Content-Type: application/json" \
-d '{"type": "cpu"}' \
http://localhost:4444/session/ID/pressuresource
```

The server responds with a null value to indicate success:

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

{"value":null}
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- [Update Virtual Pressure Source](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/UpdateVirtualPressureSource) command
- [Delete Virtual Pressure Source](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/DeleteVirtualPressureSource) command
- [Compute Pressure API](/en-US/docs/Web/API/Compute_Pressure_API)
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: Create Virtual Sensor
short-title: Create Virtual Sensor
slug: Web/WebDriver/Reference/Classic/Commands/CreateVirtualSensor
page-type: webdriver-command
browser-compat: webdriver.classic.CreateVirtualSensor
sidebar: webdriver
---

The _Create Virtual Sensor_ [command](/en-US/docs/Web/WebDriver/Reference/Classic/Commands) of the [WebDriver](/en-US/docs/Web/WebDriver) API creates a virtual sensor of a given type that overrides the platform sensor of the same type. This lets tests exercise the [Sensor APIs](/en-US/docs/Web/API/Sensor_APIs) with predetermined readings instead of relying on real hardware. While the virtual sensor exists, it replaces any real sensor of the same type for the [top-level browsing context](/en-US/docs/Glossary/Browsing_context).

## Syntax

| Method | URI template |
| ----------------------------------------------------- | ------------------------------ |
| [`POST`](/en-US/docs/Web/HTTP/Reference/Methods/POST) | `/session/{session id}/sensor` |

### URL parameters

- `session id`
- : Identifier of the session.

### Payload

The input is an object:

- `type`
- : A string identifying the virtual sensor type to create, for example `"ambient-light"`, `"accelerometer"`, or `"gyroscope"`. Only one virtual sensor of a given type can exist at a time in the top-level browsing context.
- `connected` {{optional_inline}}
- : A boolean indicating whether the sensor is able to provide readings. Defaults to `true`.
- `maxSamplingFrequency` {{optional_inline}}
- : A number specifying the upper bound, in hertz, of the sampling frequency the virtual sensor supports.
- `minSamplingFrequency` {{optional_inline}}
- : A number specifying the lower bound, in hertz, of the sampling frequency the virtual sensor supports.

### Return value

`null` if successful.

### Errors

- [`invalid session id`](/en-US/docs/Web/WebDriver/Reference/Errors/InvalidSessionID)
- : Session does not exist.
- [`invalid argument`](/en-US/docs/Web/WebDriver/Reference/Errors/InvalidArgument)
- : The `type` is not a string or is not a supported virtual sensor type, a virtual sensor of that type already exists, or the supplied frequency values are invalid (for example, not a number or `minSamplingFrequency` is greater than `maxSamplingFrequency`).

## Examples

### Creating a virtual sensor

With a WebDriver server running on `localhost:4444`, assume an active session has been created. To create a virtual [`AmbientLightSensor`](/en-US/docs/Web/API/AmbientLightSensor), send its type as the request payload, replacing `ID` with the `sessionId` from the [New Session](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/NewSession) response:

```bash
curl -i -H "Content-Type: application/json" \
-d '{"type": "ambient-light"}' \
http://localhost:4444/session/ID/sensor
```

The server responds with a null value to indicate success:

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

{"value":null}
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- [Update Virtual Sensor Reading](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/UpdateVirtualSensorReading) command
- [Get Virtual Sensor Information](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/GetVirtualSensorInformation) command
- [Delete Virtual Sensor](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/DeleteVirtualSensor) command
- [Sensor APIs](/en-US/docs/Web/API/Sensor_APIs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: Delete Virtual Pressure Source
short-title: Delete Virtual Pressure Source
slug: Web/WebDriver/Reference/Classic/Commands/DeleteVirtualPressureSource
page-type: webdriver-command
browser-compat: webdriver.classic.DeleteVirtualPressureSource
sidebar: webdriver
---

The _Delete Virtual Pressure Source_ [command](/en-US/docs/Web/WebDriver/Reference/Classic/Commands) of the [WebDriver](/en-US/docs/Web/WebDriver) API removes a virtual pressure source previously created with the [Create Virtual Pressure Source](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/CreateVirtualPressureSource) command. After the virtual pressure source is deleted, the [Compute Pressure API](/en-US/docs/Web/API/Compute_Pressure_API) once again uses the real platform pressure source of that type, if one is available.

## Syntax

| Method | URI template |
| --------------------------------------------------------- | --------------------------------------------- |
| [`DELETE`](/en-US/docs/Web/HTTP/Reference/Methods/DELETE) | `/session/{session id}/pressuresource/{type}` |

### URL parameters

- `session id`
- : Identifier of the session.
- `type`
- : The pressure source type to delete, for example `"cpu"`.

### Return value

`null` if successful.

### Errors

- [`invalid session id`](/en-US/docs/Web/WebDriver/Reference/Errors/InvalidSessionID)
- : Session does not exist.
- [`invalid argument`](/en-US/docs/Web/WebDriver/Reference/Errors/InvalidArgument)
- : The `type` is not a supported pressure source type.

## Examples

### Deleting a virtual pressure source

With a WebDriver server running on `localhost:4444`, assume a virtual `"cpu"` pressure source has been created for the active session. To remove it, send a `DELETE` request with the pressure source type appended to the endpoint, replacing `ID` with the `sessionId` from the [New Session](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/NewSession) response:

```bash
curl -i -X DELETE http://localhost:4444/session/ID/pressuresource/cpu
```

The server responds with a null value to indicate success:

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

{"value":null}
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- [Create Virtual Pressure Source](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/CreateVirtualPressureSource) command
- [Update Virtual Pressure Source](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/UpdateVirtualPressureSource) command
- [Compute Pressure API](/en-US/docs/Web/API/Compute_Pressure_API)
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
title: Delete Virtual Sensor
short-title: Delete Virtual Sensor
slug: Web/WebDriver/Reference/Classic/Commands/DeleteVirtualSensor
page-type: webdriver-command
browser-compat: webdriver.classic.DeleteVirtualSensor
sidebar: webdriver
---

The _Delete Virtual Sensor_ [command](/en-US/docs/Web/WebDriver/Reference/Classic/Commands) of the [WebDriver](/en-US/docs/Web/WebDriver) API removes a virtual sensor previously created with the [Create Virtual Sensor](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/CreateVirtualSensor) command. After the virtual sensor is deleted, the [Sensor APIs](/en-US/docs/Web/API/Sensor_APIs) once again use the real platform sensor of that type, if one is available.

## Syntax

| Method | URI template |
| --------------------------------------------------------- | ------------------------------------- |
| [`DELETE`](/en-US/docs/Web/HTTP/Reference/Methods/DELETE) | `/session/{session id}/sensor/{type}` |

### URL parameters

- `session id`
- : Identifier of the session.
- `type`
- : The virtual sensor type to delete, for example `"ambient-light"`.

### Return value

`null` if successful.

### Errors

- [`invalid session id`](/en-US/docs/Web/WebDriver/Reference/Errors/InvalidSessionID)
- : Session does not exist.
- [`invalid argument`](/en-US/docs/Web/WebDriver/Reference/Errors/InvalidArgument)
- : No virtual sensor of the given `type` exists.

## Examples

### Deleting a virtual sensor

With a WebDriver server running on `localhost:4444`, assume a virtual `"ambient-light"` sensor has been created for the active session. To remove it, send a `DELETE` request with the sensor type appended to the endpoint, replacing `ID` with the `sessionId` from the [New Session](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/NewSession) response:

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

The server responds with a null value to indicate success:

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

{"value":null}
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- [Create Virtual Sensor](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/CreateVirtualSensor) command
- [Update Virtual Sensor Reading](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/UpdateVirtualSensorReading) command
- [Get Virtual Sensor Information](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/GetVirtualSensorInformation) command
- [Sensor APIs](/en-US/docs/Web/API/Sensor_APIs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
title: Get Virtual Sensor Information
short-title: Get Virtual Sensor Information
slug: Web/WebDriver/Reference/Classic/Commands/GetVirtualSensorInformation
page-type: webdriver-command
browser-compat: webdriver.classic.GetVirtualSensorInformation
sidebar: webdriver
---

The _Get Virtual Sensor Information_ [command](/en-US/docs/Web/WebDriver/Reference/Classic/Commands) of the [WebDriver](/en-US/docs/Web/WebDriver) API returns information about a virtual sensor previously created with the [Create Virtual Sensor](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/CreateVirtualSensor) command. It reports the sampling frequency currently requested by the page, which lets a test confirm that the [Sensor APIs](/en-US/docs/Web/API/Sensor_APIs) are consuming readings at the expected rate.

## Syntax

| Method | URI template |
| --------------------------------------------------- | ------------------------------------- |
| [`GET`](/en-US/docs/Web/HTTP/Reference/Methods/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`](/en-US/docs/Web/WebDriver/Reference/Errors/InvalidSessionID)
- : Session does not exist.
- [`invalid argument`](/en-US/docs/Web/WebDriver/Reference/Errors/InvalidArgument)
- : 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](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/NewSession) 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

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- [Create Virtual Sensor](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/CreateVirtualSensor) command
- [Update Virtual Sensor Reading](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/UpdateVirtualSensorReading) command
- [Delete Virtual Sensor](/en-US/docs/Web/WebDriver/Reference/Classic/Commands/DeleteVirtualSensor) command
- [Sensor APIs](/en-US/docs/Web/API/Sensor_APIs)
Loading