Socket
Socket
Sign inDemoInstall

appium-chromedriver

Package Overview
Dependencies
14
Maintainers
0
Versions
240
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

appium-chromedriver


Version published
Maintainers
0
Created

Package description

What is appium-chromedriver?

The appium-chromedriver npm package is a Node.js wrapper around the Chromedriver binary, which is used to automate Chrome-based browsers for testing purposes. It is primarily used in conjunction with Appium to facilitate automated testing of web applications on mobile devices.

What are appium-chromedriver's main functionalities?

Install Chromedriver

This feature allows you to install the Chromedriver binary required for automating Chrome-based browsers. The code sample demonstrates how to set up Chromedriver using the appium-chromedriver package.

const Chromedriver = require('appium-chromedriver');
const driver = new Chromedriver();
driver.setupChromedriver().then(() => console.log('Chromedriver installed successfully'));

Start Chromedriver

This feature allows you to start the Chromedriver server. The code sample demonstrates how to start Chromedriver using the appium-chromedriver package.

const Chromedriver = require('appium-chromedriver');
const driver = new Chromedriver();
driver.start().then(() => console.log('Chromedriver started successfully'));

Stop Chromedriver

This feature allows you to stop the Chromedriver server. The code sample demonstrates how to stop Chromedriver using the appium-chromedriver package.

const Chromedriver = require('appium-chromedriver');
const driver = new Chromedriver();
driver.stop().then(() => console.log('Chromedriver stopped successfully'));

Get Chromedriver Status

This feature allows you to get the status of the Chromedriver server. The code sample demonstrates how to retrieve the status using the appium-chromedriver package.

const Chromedriver = require('appium-chromedriver');
const driver = new Chromedriver();
driver.status().then(status => console.log('Chromedriver status:', status));

Other packages similar to appium-chromedriver

Changelog

Source

5.6.62 (2024-06-25)

Miscellaneous Chores

  • ChromeDriver Bump to v126.0.6478.126 (#408) (4541c41)

Readme

Source

appium-chromedriver

Release

Node.js wrapper around Chromedriver and Microsoft Edge WebDriver. The Microsoft Edge WebDriver support is since v5.4.0. This wrapper is not used directly in Appium, but rather by various Android drivers to automate Chrome/Chromium-based browsers and web views using Hybrid Mode approach. Check the corresponding driver tutorials to get more details on it.

Note

This package is intended to be used as a helper module for Appium drivers such as UiAutomator2 and appium-chromium-driver. It was not created for standalone usage. Please ensure you know what you are doing before using this package directly.

Note

This package can work with Microsoft Edge WebDriver as well, but the support is limited. For example, automatic downloads do not work for Microsoft Edge WebDriver.

Skipping binary installation

By default, upon installation the package downloads the most recent known Chromedriver version from Chromedriver CDN server: http://chromedriver.storage.googleapis.com. If, for some reason, you want to install the package without downloading the Chromedriver binary set the APPIUM_SKIP_CHROMEDRIVER_INSTALL environment variable:

APPIUM_SKIP_CHROMEDRIVER_INSTALL=1 npm install appium-chromedriver

Custom Chromedriver version

By default, the package uses the most recent known Chromedriver version. The full list of known Chromedriver versions and their corresponding supported Chrome version could be found in mapping.json

To download a custom version of Chromedriver, please set CHROMEDRIVER_VERSION environment variable:

CHROMEDRIVER_VERSION=107.0.5304.62 npm install appium-chromedriver

Custom binaries url

If you want Chromedriver to be downloaded from another CDN, which differs from the default one https://chromedriver.storage.googleapis.com, then either set the npm config property chromedriver_cdnurl:

npm install appium-chromedriver --chromedriver_cdnurl=http://npm.taobao.org/mirrors/chromedriver

The property could also be added into your .npmrc file.

chromedriver_cdnurl=http://npm.taobao.org/mirrors/chromedriver

Or set the new URL to CHROMEDRIVER_CDNURL environment variable:

CHROMEDRIVER_CDNURL=http://npm.taobao.org/mirrors/chromedriver npm install appium-chromedriver

If you want automatic chromedrivers download feature to work with a custom CDN URL then make sure the server returns a proper list of stored drivers in response to requests having Accept: application/xml header. An example XML could be retrieved from the original URL using curl -H 'Accept: application/xml' https://chromedriver.storage.googleapis.com command.

Since version 5.6 the second environment variable has been added: CHROMELABS_URL. By default, it points to https://googlechromelabs.github.io, and is expected to contain the actual prefix of Chrome for Testing availability JSON API. This API allows retrieval of chromedrivers whose versions are greater than 114.

Similarly to the above it could be also defined in the .npmrc file:

chromelabs_url=https://googlechromelabs.github.io

You may also want to skip checking for older Chromedriver versions by providing an empty value to the CHROMEDRIVER_CDNURL variable.

Usage

import Chromedriver from 'appium-chromedriver';

// 'sync'-like await/Promise usage
async function runSession() {
    let driver = new Chromedriver();
    const desiredCaps = {browserName: 'chrome'};
    await driver.start(desiredCaps);
    let status = await driver.sendCommand('/status', 'GET');
    await driver.stop();
}

// EventEmitter usage
function runSession2() {
    let driver = new Chromedriver();
    const desiredCaps = {browserName: 'chrome'};
    driver.start(desiredCaps);
    driver.on(Chromedriver.EVENT_CHANGED, function (msg) {
        if (msg.state === Chromedriver.STATE_ONLINE) {
            driver.sendCommand('/status', 'GET').then(function (status) {
                driver.stop();
            });
        }
    });
    driver.on(Chromedriver.EVENT_ERROR, function (err) {
        // :-(
    });
}

States

Here's what the Chromedriver state machine looks like:

Chromedriver States

Here are the events you can listen for:

  • Chromedriver.EVENT_ERROR: gives you an error object
  • Chromedriver.EVENT_CHANGED: gives you a state change object, with a state property that can be one of:
    • Chromedriver.STATE_STOPPED
    • Chromedriver.STATE_STARTING
    • Chromedriver.STATE_ONLINE
    • Chromedriver.STATE_STOPPING
    • Chromedriver.STATE_RESTARTING

Development

Build & Lint

npm run build
npm run lint

Run Tests

npm run test
npm run e2e-test

Keywords

FAQs

Last updated on 25 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc