# Chromium

## isAlertOpen[​](#isalertopen "Direct link to isAlertOpen")

Whether a simple dialog is currently open.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/alert_commands.cc#L42-L49).

### Usage[​](#usage "Direct link to Usage")

```
await browser.isAlertOpen()
```

### Example[​](#example "Direct link to Example")

```
console.log(browser.isAlertOpen()); // outputs: false
browser.execute('window.alert()');
console.log(browser.isAlertOpen()); // outputs: true
```

### Returns[​](#returns "Direct link to Returns")

* **\<Boolean>** **`isAlertOpen`:** `true` or `false` based on whether simple dialog is present or not.

***

## isAutoReporting[​](#isautoreporting "Direct link to isAutoReporting")

Whether it should automatically raises errors on browser logs.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://codereview.chromium.org/101203012).

### Usage[​](#usage-1 "Direct link to Usage")

```
await browser.isAutoReporting()
```

### Returns[​](#returns-1 "Direct link to Returns")

* **\<Boolean>** **`isAutoReporting`:** `true` or `false` based on whether auto reporting is enabled.

***

## setAutoReporting[​](#setautoreporting "Direct link to setAutoReporting")

Toggle whether to return response with unknown error with first browser error (e.g. failed to load resource due to 403/404 response) for all subsequent commands (once enabled).<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://codereview.chromium.org/101203012).

### Usage[​](#usage-2 "Direct link to Usage")

```
await browser.setAutoReporting(enabled)
```

### Parameters[​](#parameters "Direct link to Parameters")

| Name      | Type      | Details                                                                                               |
| --------- | --------- | ----------------------------------------------------------------------------------------------------- |
| `enabled` | `boolean` | `true` if auto reporting should be enabled, use `false` to disable previously enabled auto reporting. |

### Examples[​](#examples "Direct link to Examples")

```
// Enable auto reporting first thing after session was initiated with empty browser logs
console.log(browser.setAutoReporting(true)); // outputs: null
// Upon requesting an non-existing resource it will abort execution due to thrown unknown error
browser.url('https://webdriver.io/img/404-does-not-exist.png');
```

```
// During the session do some operations which populate the browser logs
browser.url('https://webdriver.io/img/404-does-not-exist.png');
browser.url('https://webdriver.io/403/no-access');
// Enable auto reporting which throws an unknown error for first browser log (404 response)
browser.setAutoReporting(true);
```

### Returns[​](#returns-2 "Direct link to Returns")

* **\<Object|Null>** **`firstBrowserError`:** In case first browser error already occured prior to executing this command it will throw unknown error as response, which is an object with 'message' key describing first browser error. Otherwise it returns `null` on success.

***

## isLoading[​](#isloading "Direct link to isLoading")

Determines load status for active window handle.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/session_commands.cc#L783-L802).

### Usage[​](#usage-3 "Direct link to Usage")

```
await browser.isLoading()
```

### Example[​](#example-1 "Direct link to Example")

```
console.log(browser.isLoading()); // outputs: false
browser.newWindow('https://webdriver.io');
console.log(browser.isLoading()); // outputs: true
```

### Returns[​](#returns-3 "Direct link to Returns")

* **\<Boolean>** **`isLoading`:** `true` or `false` based on whether active window handle is loading or not.

***

## takeHeapSnapshot[​](#takeheapsnapshot "Direct link to takeHeapSnapshot")

Takes a heap snapshot of the current execution context.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/chrome/web_view.h#L198-L202).

### Usage[​](#usage-4 "Direct link to Usage")

```
await browser.takeHeapSnapshot()
```

### Returns[​](#returns-4 "Direct link to Returns")

* **\<Object>** **`heapSnapshot`:** A JSON representation of the heap snapshot. Which can be inspected by loading as file into Chrome DevTools.

***

## getNetworkConnection[​](#getnetworkconnection "Direct link to getNetworkConnection")

Get the connection type for network emulation. This command is only applicable when remote end replies with `networkConnectionEnabled` capability set to `true`.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#device-modes).

### Usage[​](#usage-5 "Direct link to Usage")

```
await browser.getNetworkConnection()
```

### Example[​](#example-2 "Direct link to Example")

```
const browser = remote({
    capabilities: {
        browserName: 'chrome',
        'goog:chromeOptions': {
            // Network emulation requires device mode, which is only enabled when mobile emulation is on
            mobileEmulation: { deviceName: 'iPad' },
        },
    }
});
console.log(browser.getNetworkConnection()); // outputs: 6 (Both Wi-Fi and data)
```

### Returns[​](#returns-5 "Direct link to Returns")

* **\<Number>** **`connectionType`:** A bitmask to represent the network connection type. Airplane Mode (`1`), Wi-Fi only (`2`), Wi-Fi and data (`6`), 4G (`8`), 3G (`10`), 2G (`20`). By default [Wi-Fi and data are enabled](https://github.com/bayandin/chromedriver/blob/v2.45/chrome/chrome_desktop_impl.cc#L36-L37).

***

## setNetworkConnection[​](#setnetworkconnection "Direct link to setNetworkConnection")

Change connection type for network connection. This command is only applicable when remote end replies with `networkConnectionEnabled` capability set to `true`.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md#device-modes).

### Usage[​](#usage-6 "Direct link to Usage")

```
await browser.setNetworkConnection(parameters)
```

### Parameters[​](#parameters-1 "Direct link to Parameters")

| Name         | Type     | Details                                                                                                                                                                       |
| ------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `parameters` | `object` | Object containing ConnectionType, set bitmask as value for `type` key in object. Airplane Mode (`1`), Wi-Fi only (`2`), Wi-Fi and data (`6`), 4G (`8`), 3G (`10`), 2G (`20`). |

### Example[​](#example-3 "Direct link to Example")

```
const browser = remote({
    capabilities: {
        browserName: 'chrome',
        'goog:chromeOptions': {
            // Network emulation requires device mode, which is only enabled when mobile emulation is on
            mobileEmulation: { deviceName: 'iPad' },
        },
    }
});
console.log(browser.setNetworkConnection({ type: 1 })); // outputs: 1 (Airplane Mode)
```

### Returns[​](#returns-6 "Direct link to Returns")

* **\<Number>** **`connectionType`:** A bitmask to represent the network connection type. Value should match specified `type` in object, however device might not be capable of the network connection type requested.

***

## getNetworkConditions[​](#getnetworkconditions "Direct link to getNetworkConditions")

Get current network conditions used for emulation.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/session_commands.cc#L839-L859).

### Usage[​](#usage-7 "Direct link to Usage")

```
await browser.getNetworkConditions()
```

### Returns[​](#returns-7 "Direct link to Returns")

* **\<Object>** **`networkConditions`:** Object containing network conditions for `offline`, `latency`, `download_throughput` and `upload_throughput`. Network conditions must be set before it can be retrieved.

***

## setNetworkConditions[​](#setnetworkconditions "Direct link to setNetworkConditions")

Set network conditions used for emulation by throttling connection.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/window_commands.cc#L1663-L1722).

### Usage[​](#usage-8 "Direct link to Usage")

```
await browser.setNetworkConditions(network_conditions, network_name)
```

### Parameters[​](#parameters-2 "Direct link to Parameters")

| Name                           | Type     | Details                                                                                                                                                                                                                                                                                                                   |
| ------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `network_conditions`           | `object` | Object containing network conditions which are `latency`, `throughput` (or `download_throughput`/`upload_throughput`) and `offline` (optional).                                                                                                                                                                           |
| `network_name`<br />*optional* | `string` | Name of [network throttling preset](https://github.com/bayandin/chromedriver/blob/v2.45/chrome/network_list.cc#L12-L25). `GPRS`, `Regular 2G`, `Good 2G`, `Regular 3G`, `Good 3G`, `Regular 4G`, `DSL`, `WiFi` or `No throttling` to disable. When preset is specified values passed in first argument are not respected. |

### Examples[​](#examples-1 "Direct link to Examples")

```
// Use different download (25kb/s) and upload (50kb/s) throughput values for throttling with a latency of 1000ms
browser.setNetworkConditions({ latency: 1000, download_throughput: 25600, upload_throughput: 51200 });
```

```
// Force disconnected from network by setting 'offline' to true
browser.setNetworkConditions({ latency: 0, throughput: 0, offline: true });
```

```
// When preset name (e.g. 'DSL') is specified it does not respect values in object (e.g. 'offline')
browser.setNetworkConditions({ latency: 0, throughput: 0, offline: true }, 'DSL');
```

```
// Best practice for specifying network throttling preset is to use an empty object
browser.setNetworkConditions({}, 'Good 3G');
```

***

## deleteNetworkConditions[​](#deletenetworkconditions "Direct link to deleteNetworkConditions")

Disable any network throttling which might have been set. Equivalent of setting the `No throttling` preset.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/window_commands.cc#L1724-L1745).

### Usage[​](#usage-9 "Direct link to Usage")

```
await browser.deleteNetworkConditions()
```

***

## sendCommand[​](#sendcommand "Direct link to sendCommand")

Send a command to the DevTools debugger.<br />For a list of available commands and their parameters refer to the [Chrome DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/).<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/window_commands.cc#L1290-L1304).

### Usage[​](#usage-10 "Direct link to Usage")

```
await browser.sendCommand(cmd, params)
```

### Parameters[​](#parameters-3 "Direct link to Parameters")

| Name     | Type     | Details                                                                                                                    |
| -------- | -------- | -------------------------------------------------------------------------------------------------------------------------- |
| `cmd`    | `string` | Name of the command (e.g. [`Browser.close`](https://chromedevtools.github.io/devtools-protocol/1-3/Browser#method-close)). |
| `params` | `object` | Parameters to the command. In case no parameters for command, specify an empty object.                                     |

***

## sendCommandAndGetResult[​](#sendcommandandgetresult "Direct link to sendCommandAndGetResult")

Send a command to the DevTools debugger and wait for the result.<br />For a list of available commands and their parameters refer to the [Chrome DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/).<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/window_commands.cc#L1306-L1320).

### Usage[​](#usage-11 "Direct link to Usage")

```
await browser.sendCommandAndGetResult(cmd, params)
```

### Parameters[​](#parameters-4 "Direct link to Parameters")

| Name     | Type     | Details                                                                                                                                                           |
| -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cmd`    | `string` | Name of the command which returns a result (e.g. [`Network.getAllCookies`](https://chromedevtools.github.io/devtools-protocol/1-3/Network#method-getAllCookies)). |
| `params` | `object` | Parameters to the command. In case no parameters for command, specify an empty object.                                                                            |

### Returns[​](#returns-8 "Direct link to Returns")

* **<\*>** **`result`:** Either the return value of your command, or the error which was the reason for your command's failure.

***

## file[​](#file "Direct link to file")

Upload a file to remote machine on which the browser is running.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/session_commands.cc#L1037-L1065).

### Usage[​](#usage-12 "Direct link to Usage")

```
await browser.file(file)
```

### Parameters[​](#parameters-5 "Direct link to Parameters")

| Name   | Type     | Details                                                                                                                                                                                                    |
| ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `file` | `string` | Base64-encoded zip archive containing **single** file which to upload. In case base64-encoded data does not represent a zip archive or archive contains more than one file it will throw an unknown error. |

### Returns[​](#returns-9 "Direct link to Returns")

* **\<String>** **`path`:** Absolute path of uploaded file on remote machine.

***

## launchChromeApp[​](#launchchromeapp "Direct link to launchChromeApp")

Launches a Chrome app by specified id.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/session_commands.cc#L521-L539).

### Usage[​](#usage-13 "Direct link to Usage")

```
await browser.launchChromeApp(id)
```

### Parameters[​](#parameters-6 "Direct link to Parameters")

| Name | Type     | Details                                                                |
| ---- | -------- | ---------------------------------------------------------------------- |
| `id` | `string` | Extension id of app to be launched, as defined in chrome://extensions. |

### Example[​](#example-4 "Direct link to Example")

```
import fs from 'fs'
const browser = remote({
    capabilities: {
        browserName: 'chrome',
        'goog:chromeOptions': {
            // Install upon starting browser in order to launch it
            extensions: [
              // Entry should be a base64-encoded packed Chrome app (.crx)
              fs.readFileSync('/absolute/path/app.crx').toString('base64')
            ]
        }
    }
});
browser.launchChromeApp('aohghmighlieiainnegkcijnfilokake')); // Google Docs (https://chrome.google.com/webstore/detail/docs/aohghmighlieiainnegkcijnfilokake)
```

***

## getElementValue[​](#getelementvalue "Direct link to getElementValue")

Retrieves the value of a given form control element.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/element_commands.cc#L431-L443).

### Usage[​](#usage-14 "Direct link to Usage")

```
await browser.getElementValue(elementId)
```

### Parameters[​](#parameters-7 "Direct link to Parameters")

| Name        | Type     | Details                         |
| ----------- | -------- | ------------------------------- |
| `elementId` | `String` | id of element to get value from |

### Returns[​](#returns-10 "Direct link to Returns")

* **\<String|Null>** **`value`:** Current value of the element. In case specified element is not a form control element, it will return `null`.

***

## elementHover[​](#elementhover "Direct link to elementHover")

Enable hover state for an element, which is reset upon next interaction.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/element_commands.cc#L126-L146).

### Usage[​](#usage-15 "Direct link to Usage")

```
await browser.elementHover(elementId)
```

### Parameters[​](#parameters-8 "Direct link to Parameters")

| Name        | Type     | Details                        |
| ----------- | -------- | ------------------------------ |
| `elementId` | `String` | id of element to hover over to |

***

## touchPinch[​](#touchpinch "Direct link to touchPinch")

Trigger a pinch zoom effect.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/window_commands.cc#L813-L827).

### Usage[​](#usage-16 "Direct link to Usage")

```
await browser.touchPinch(x, y, scale)
```

### Parameters[​](#parameters-9 "Direct link to Parameters")

| Name    | Type     | Details                |
| ------- | -------- | ---------------------- |
| `x`     | `number` | x position to pinch on |
| `y`     | `number` | y position to pinch on |
| `scale` | `number` | pinch zoom scale       |

***

## freeze[​](#freeze "Direct link to freeze")

Freeze the current page. Extension for [Page Lifecycle API](https://developers.google.com/web/updates/2018/07/page-lifecycle-api).<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/window_commands.cc#L625-L633).

### Usage[​](#usage-17 "Direct link to Usage")

```
await browser.freeze()
```

***

## resume[​](#resume "Direct link to resume")

Resume the current page. Extension for [Page Lifecycle API](https://developers.google.com/web/updates/2018/07/page-lifecycle-api).<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/window_commands.cc#L635-L645).

### Usage[​](#usage-18 "Direct link to Usage")

```
await browser.resume()
```

***

## getCastSinks[​](#getcastsinks "Direct link to getCastSinks")

Returns the list of cast sinks (Cast devices) available to the Chrome media router.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://chromium.googlesource.com/chromium/src/+/refs/tags/73.0.3683.121/chrome/test/chromedriver/server/http_handler.cc#748).

### Usage[​](#usage-19 "Direct link to Usage")

```
await browser.getCastSinks()
```

### Returns[​](#returns-11 "Direct link to Returns")

* **\<string\[]>** **`sinks`:** List of available sinks.

***

## selectCastSink[​](#selectcastsink "Direct link to selectCastSink")

Selects a cast sink (Cast device) as the recipient of media router intents (connect or play).<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://chromium.googlesource.com/chromium/src/+/refs/tags/73.0.3683.121/chrome/test/chromedriver/server/http_handler.cc#737).

### Usage[​](#usage-20 "Direct link to Usage")

```
await browser.selectCastSink(sinkName)
```

### Parameters[​](#parameters-10 "Direct link to Parameters")

| Name       | Type     | Details                        |
| ---------- | -------- | ------------------------------ |
| `sinkName` | `string` | The name of the target device. |

***

## startCastTabMirroring[​](#startcasttabmirroring "Direct link to startCastTabMirroring")

Initiates tab mirroring for the current browser tab on the specified device.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://chromium.googlesource.com/chromium/src/+/refs/tags/73.0.3683.121/chrome/test/chromedriver/server/http_handler.cc#741).

### Usage[​](#usage-21 "Direct link to Usage")

```
await browser.startCastTabMirroring(sinkName)
```

### Parameters[​](#parameters-11 "Direct link to Parameters")

| Name       | Type     | Details                        |
| ---------- | -------- | ------------------------------ |
| `sinkName` | `string` | The name of the target device. |

***

## getCastIssueMessage[​](#getcastissuemessage "Direct link to getCastIssueMessage")

Returns error message if there is any issue in a Cast session.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://chromium.googlesource.com/chromium/src/+/refs/tags/73.0.3683.121/chrome/test/chromedriver/server/http_handler.cc#751).

### Usage[​](#usage-22 "Direct link to Usage")

```
await browser.getCastIssueMessage()
```

### Returns[​](#returns-12 "Direct link to Returns")

* **\<String>** **`message`:** Error message, if any.

***

## stopCasting[​](#stopcasting "Direct link to stopCasting")

Stops casting from media router to the specified device, if connected.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://chromium.googlesource.com/chromium/src/+/refs/tags/73.0.3683.121/chrome/test/chromedriver/server/http_handler.cc#744).

### Usage[​](#usage-23 "Direct link to Usage")

```
await browser.stopCasting(sinkName)
```

### Parameters[​](#parameters-12 "Direct link to Parameters")

| Name       | Type     | Details                        |
| ---------- | -------- | ------------------------------ |
| `sinkName` | `string` | The name of the target device. |

***

## shutdown[​](#shutdown "Direct link to shutdown")

Shutdown ChromeDriver process and consequently terminating all active sessions.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/bayandin/chromedriver/blob/v2.45/session_commands.cc#L489-L498).

### Usage[​](#usage-24 "Direct link to Usage")

```
await browser.shutdown()
```

***

## takeElementScreenshot[​](#takeelementscreenshot "Direct link to takeElementScreenshot")

The Take Element Screenshot command takes a screenshot of the visible region encompassed by the bounding rectangle of an element.<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://w3c.github.io/webdriver/#dfn-take-element-screenshot).

### Usage[​](#usage-25 "Direct link to Usage")

```
await browser.takeElementScreenshot(elementId)
```

### Parameters[​](#parameters-13 "Direct link to Parameters")

| Name        | Type     | Details                                                             |
| ----------- | -------- | ------------------------------------------------------------------- |
| `elementId` | `String` | the id of an element returned in a previous call to Find Element(s) |

### Returns[​](#returns-13 "Direct link to Returns")

* **\<String>** **`screenshot`:** The base64-encoded PNG image data comprising the screenshot of the visible region of an element’s bounding rectangle after it has been scrolled into view.

***

## getLogTypes[​](#getlogtypes "Direct link to getLogTypes")

Get available log types.<br /><br />Appium command. More details can be found in the [official protocol docs](https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidlogtypes).<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidlogtypes).

### Usage[​](#usage-26 "Direct link to Usage")

```
await browser.getLogTypes()
```

### Returns[​](#returns-14 "Direct link to Returns")

* **\<String\[]>** **`logTypes`:** The list of available log types, example: browser, driver.

***

## getLogs[​](#getlogs "Direct link to getLogs")

Get the log for a given log type. Log buffer is reset after each request.<br /><br />Appium command. More details can be found in the [official protocol docs](https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidlog).<br /><br />Non official and undocumented Chromium command. More about this command can be found [here](https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidlog).

### Usage[​](#usage-27 "Direct link to Usage")

```
await browser.getLogs(type)
```

### Parameters[​](#parameters-14 "Direct link to Parameters")

| Name   | Type     | Details      |
| ------ | -------- | ------------ |
| `type` | `string` | the log type |

### Returns[​](#returns-15 "Direct link to Returns")

* **\<Object\[]>** **`logs`:** The list of log entries.
