Chromium
isAlertOpenโ
Whether a simple dialog is currently open.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.isAlertOpen()
Exampleโ
console.log(browser.isAlertOpen()); // outputs: false
browser.execute('window.alert()');
console.log(browser.isAlertOpen()); // outputs: true
Returnsโ
- <Boolean>
isAlertOpen:trueorfalsebased on whether simple dialog is present or not.
isAutoReportingโ
Whether it should automatically raises errors on browser logs.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.isAutoReporting()
Returnsโ
- <Boolean>
isAutoReporting:trueorfalsebased on whether auto reporting is enabled.
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).
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.setAutoReporting(enabled)
Parametersโ
| Name | Type | Details |
|---|---|---|
enabled | boolean | true if auto reporting should be enabled, use false to disable previously enabled auto reporting. |
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โ
- <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 returnsnullon success.
isLoadingโ
Determines load status for active window handle.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.isLoading()
Exampleโ
console.log(browser.isLoading()); // outputs: false
browser.newWindow('https://webdriver.io');
console.log(browser.isLoading()); // outputs: true
Returnsโ
- <Boolean>
isLoading:trueorfalsebased on whether active window handle is loading or not.
takeHeapSnapshotโ
Takes a heap snapshot of the current execution context.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.takeHeapSnapshot()
Returnsโ
- <Object>
heapSnapshot: A JSON representation of the heap snapshot. Which can be inspected by loading as file into Chrome DevTools.
getNetworkConnectionโ
Get the connection type for network emulation. This command is only applicable when remote end replies with networkConnectionEnabled capability set to true.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.getNetworkConnection()
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โ
- <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.
setNetworkConnectionโ
Change connection type for network connection. This command is only applicable when remote end replies with networkConnectionEnabled capability set to true.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.setNetworkConnection(parameters)
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โ
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โ
- <Number>
connectionType: A bitmask to represent the network connection type. Value should match specifiedtypein object, however device might not be capable of the network connection type requested.
getNetworkConditionsโ
Get current network conditions used for emulation.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.getNetworkConditions()
Returnsโ
- <Object>
networkConditions: Object containing network conditions foroffline,latency,download_throughputandupload_throughput. Network conditions must be set before it can be retrieved.
setNetworkConditionsโ
Set network conditions used for emulation by throttling connection.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.setNetworkConditions(network_conditions, network_name)
Parametersโ
| Name | Type | Details |
|---|---|---|
network_conditions | object | Object containing network conditions which are latency, throughput (or download_throughput/upload_throughput) and offline (optional). |
network_nameoptional | string | Name of network throttling preset. 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โ
// 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โ
Disable any network throttling which might have been set. Equivalent of setting the No throttling preset.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.deleteNetworkConditions()
sendCommandโ
Send a command to the DevTools debugger.
For a list of available commands and their parameters refer to the Chrome DevTools Protocol Viewer.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.sendCommand(cmd, params)
Parametersโ
| Name | Type | Details |
|---|---|---|
cmd | string | Name of the command (e.g. Browser.close). |
params | object | Parameters to the command. In case no parameters for command, specify an empty object. |
sendCommandAndGetResultโ
Send a command to the DevTools debugger and wait for the result.
For a list of available commands and their parameters refer to the Chrome DevTools Protocol Viewer.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.sendCommandAndGetResult(cmd, params)
Parametersโ
| Name | Type | Details |
|---|---|---|
cmd | string | Name of the command which returns a result (e.g. Network.getAllCookies). |
params | object | Parameters to the command. In case no parameters for command, specify an empty object. |
Returnsโ
- <*>
result: Either the return value of your command, or the error which was the reason for your command's failure.
fileโ
Upload a file to remote machine on which the browser is running.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.file(file)
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โ
- <String>
path: Absolute path of uploaded file on remote machine.
launchChromeAppโ
Launches a Chrome app by specified id.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.launchChromeApp(id)
Parametersโ
| Name | Type | Details |
|---|---|---|
id | string | Extension id of app to be launched, as defined in chrome://extensions. |
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โ
Retrieves the value of a given form control element.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.getElementValue(elementId)
Parametersโ
| Name | Type | Details |
|---|---|---|
elementId | String | id of element to get value from |
Returnsโ
- <String|Null>
value: Current value of the element. In case specified element is not a form control element, it will returnnull.
elementHoverโ
Enable hover state for an element, which is reset upon next interaction.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.elementHover(elementId)
Parametersโ
| Name | Type | Details |
|---|---|---|
elementId | String | id of element to hover over to |
touchPinchโ
Trigger a pinch zoom effect.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.touchPinch(x, y, scale)
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 the current page. Extension for Page Lifecycle API.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.freeze()
resumeโ
Resume the current page. Extension for Page Lifecycle API.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.resume()
getCastSinksโ
Returns the list of cast sinks (Cast devices) available to the Chrome media router.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.getCastSinks()
Returnsโ
- <string[]>
sinks: List of available sinks.
selectCastSinkโ
Selects a cast sink (Cast device) as the recipient of media router intents (connect or play).
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.selectCastSink(sinkName)
Parametersโ
| Name | Type | Details |
|---|---|---|
sinkName | string | The name of the target device. |
startCastTabMirroringโ
Initiates tab mirroring for the current browser tab on the specified device.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.startCastTabMirroring(sinkName)
Parametersโ
| Name | Type | Details |
|---|---|---|
sinkName | string | The name of the target device. |
getCastIssueMessageโ
Returns error message if there is any issue in a Cast session.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.getCastIssueMessage()
Returnsโ
- <String>
message: Error message, if any.
stopCastingโ
Stops casting from media router to the specified device, if connected.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.stopCasting(sinkName)
Parametersโ
| Name | Type | Details |
|---|---|---|
sinkName | string | The name of the target device. |
shutdownโ
Shutdown ChromeDriver process and consequently terminating all active sessions.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.shutdown()
takeElementScreenshotโ
The Take Element Screenshot command takes a screenshot of the visible region encompassed by the bounding rectangle of an element.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.takeElementScreenshot(elementId)
Parametersโ
| Name | Type | Details |
|---|---|---|
elementId | String | the id of an element returned in a previous call to Find Element(s) |
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โ
Get available log types.
Appium command. More details can be found in the official protocol docs.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.getLogTypes()
Returnsโ
- <String[]>
logTypes: The list of available log types, example: browser, driver.
getLogsโ
Get the log for a given log type. Log buffer is reset after each request.
Appium command. More details can be found in the official protocol docs.
Non official and undocumented Chromium command. More about this command can be found here.
Usageโ
browser.getLogs(type)
Parametersโ
| Name | Type | Details |
|---|---|---|
type | string | the log type |
Returnsโ
- <Object[]>
logs: The list of log entries.