selenium-webdriver
The official WebDriver JavaScript bindings from the Selenium project
Last updated 4 years ago by sriharsha .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install selenium-webdriver 
SYNC missed versions from official npm registry.

selenium-webdriver

Selenium is a browser automation library. Most often used for testing web-applications, Selenium may be used for any task that requires automating interaction with the browser.

Installation

Selenium may be installed via npm with

npm install selenium-webdriver

You will need to download additional components to work with each of the major browsers. The drivers for Chrome, Firefox, and Microsoft's IE and Edge web browsers are all standalone executables that should be placed on your system PATH. Apple's safaridriver (v10 and above) can be found at the following path – /usr/bin/safaridriver. To enable automation on safari, you need to run command safaridriver --enable.

Browser Component
Chrome chromedriver(.exe)
Internet Explorer IEDriverServer.exe
Edge MicrosoftWebDriver.msi
Firefox geckodriver(.exe)
Opera operadriver(.exe)
Safari safaridriver

Usage

The sample below and others are included in the example directory. You may also find the tests for selenium-webdriver informative.

const { Builder, Browser, By, Key, until } = require('selenium-webdriver')

;(async function example() {
  let driver = await new Builder().forBrowser(Browser.FIREFOX).build()
  try {
    await driver.get('https://www.google.com/ncr')
    await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
    await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
  } finally {
    await driver.quit()
  }
})()

Using the Builder API

The Builder class is your one-stop shop for configuring new WebDriver instances. Rather than clutter your code with branches for the various browsers, the builder lets you set all options in one flow. When you call Builder#build(), all options irrelevant to the selected browser are dropped:

const webdriver = require('selenium-webdriver')
const chrome = require('selenium-webdriver/chrome')
const firefox = require('selenium-webdriver/firefox')

let driver = new webdriver.Builder()
  .forBrowser(webdriver.Browser.FIREFOX)
  .setChromeOptions(/* ... */)
  .setFirefoxOptions(/* ... */)
  .build()

Why would you want to configure options irrelevant to the target browser? The Builder's API defines your default configuration. You can change the target browser at runtime through the SELENIUM_BROWSER environment variable. For example, the example/google_search.js script is configured to run against Firefox. You can run the example against other browsers just by changing the runtime environment

# cd node_modules/selenium-webdriver
node example/google_search
SELENIUM_BROWSER=chrome node example/google_search
SELENIUM_BROWSER=safari node example/google_search

The Standalone Selenium Server

The standalone Selenium Server acts as a proxy between your script and the browser-specific drivers. The server may be used when running locally, but it's not recommend as it introduces an extra hop for each request and will slow things down. The server is required, however, to use a browser on a remote host (most browser drivers, like the IEDriverServer, do not accept remote connections).

To use the Selenium Server, you will need to install the JDK and download the latest server from Selenium. Once downloaded, run the server with

java -jar selenium-server-4.4.0.jar standalone

You may configure your tests to run against a remote server through the Builder API:

let driver = new webdriver.Builder()
  .forBrowser(webdriver.Browser.FIREFOX)
  .usingServer('http://localhost:4444/wd/hub')
  .build()

Or change the Builder's configuration at runtime with the SELENIUM_REMOTE_URL environment variable:

SELENIUM_REMOTE_URL="http://localhost:4444/wd/hub" node script.js

You can experiment with these options using the example/google_search.js script provided with selenium-webdriver.

Documentation

API documentation is available online from the Selenium project. Additional resources include

Contributing

Contributions are accepted either through GitHub pull requests or patches via the Selenium issue tracker.

Node Support Policy

Each version of selenium-webdriver will support the latest semver-minor version of the LTS and stable Node releases. All semver-major & semver-minor versions between the LTS and stable release will have "best effort" support. Following a Selenium release, any semver-minor Node releases will also have "best effort" support. Releases older than the latest LTS, semver-major releases, and all unstable release branches (e.g. "v.Next") are considered strictly unsupported.

For example, suppose the current LTS and stable releases are v14.20.0 and v18.8.0, respectively. Then a Selenium release would have the following support levels:

Version Support
<= 14.19 unsupported
14.20.0 supported
18.0-7 best effort
18.8.0 supported
>= 18.8.0 best effort
v.Next unsupported

Support Level Definitions

  • supported: A selenium-webdriver release will be API compatible with the platform API, without the use of runtime flags.

  • best effort: Bugs will be investigated as time permits. API compatibility is only guaranteed where required by a supported release. This effectively means the adoption of new JS features, such as ES2015 modules, will depend on what is supported in Node's LTS.

  • unsupported: Bug submissions will be closed as will-not-fix and API compatibility is not guaranteed.

Projected Support Schedule

If Node releases a new LTS each October and a new major version every 6 months, the support window for selenium-webdriver will be roughly:

Release Status END-OF-LIFE
v14.x Maintenance LTS 2023-04-30
v16.x Active LTS 2023-09-11
v18.x Current 2025-04-30
v19.x Pending 2023-06-01
v20 Pending 2026-04-30

Issues

Please report any issues using the Selenium issue tracker. When using the issue tracker

  • Do include a detailed description of the problem.
  • Do include a link to a gist with any interesting stack traces/logs (you may also attach these directly to the bug report).
  • Do include a reduced test case. Reporting "unable to find element on the page" is not a valid report - there's nothing for us to look into. Expect your bug report to be closed if you do not provide enough information for us to investigate.
  • Do not use the issue tracker to submit basic help requests. All help inquiries should be directed to the user forum or #selenium IRC channel.
  • Do not post empty "I see this too" or "Any updates?" comments. These provide no additional information and clutter the log.
  • Do not report regressions on closed bugs as they are not actively monitored for updates (especially bugs that are >6 months old). Please open a new issue and reference the original bug in your report.

License

Licensed to the Software Freedom Conservancy (SFC) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The SFC licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Current Tags

  • 4.24.0                                ...           latest (3 months ago)

94 Versions

  • 4.24.0                                ...           3 months ago
  • 4.23.0                                ...           4 months ago
  • 4.22.0                                ...           5 months ago
  • 4.21.0                                ...           6 months ago
  • 4.20.0                                ...           7 months ago
  • 4.19.0                                ...           8 months ago
  • 4.18.1                                ...           9 months ago
  • 4.18.0                                ...           9 months ago
  • 4.17.0                                ...           10 months ago
  • 4.16.0                                ...           a year ago
  • 4.15.0                                ...           a year ago
  • 4.14.0                                ...           a year ago
  • 4.13.0                                ...           a year ago
  • 4.12.0                                ...           a year ago
  • 4.11.1                                ...           a year ago
  • 4.11.0                                ...           a year ago
  • 4.10.0                                ...           a year ago
  • 4.9.2                                ...           2 years ago
  • 4.9.1                                ...           2 years ago
  • 4.9.0                                ...           2 years ago
  • 4.8.2                                ...           2 years ago
  • 4.8.1                                ...           2 years ago
  • 4.8.0                                ...           2 years ago
  • 4.7.1                                ...           2 years ago
  • 4.7.0                                ...           2 years ago
  • 4.6.1                                ...           2 years ago
  • 4.6.0                                ...           2 years ago
  • 4.5.0                                ...           2 years ago
  • 4.4.0                                ...           2 years ago
  • 4.3.1                                ...           2 years ago
  • 4.3.0                                ...           2 years ago
  • 4.2.0                                ...           2 years ago
  • 4.1.2                                ...           3 years ago
  • 4.1.1                                ...           3 years ago
  • 4.1.0                                ...           3 years ago
  • 4.0.0                                ...           3 years ago
  • 4.0.0-rc-2                                ...           3 years ago
  • 4.0.0-rc-1                                ...           3 years ago
  • 4.0.0-beta.4                                ...           3 years ago
  • 4.0.0-beta.3                                ...           4 years ago
  • 4.0.0-beta.2                                ...           4 years ago
  • 4.0.0-beta.1                                ...           4 years ago
  • 4.0.0-alpha.8                                ...           4 years ago
  • 4.0.0-alpha.7                                ...           5 years ago
  • 4.0.0-alpha.6                                ...           5 years ago
  • 4.0.0-alpha.5                                ...           5 years ago
  • 4.0.0-alpha.4                                ...           5 years ago
  • 4.0.0-alpha.3                                ...           5 years ago
  • 4.0.0-alpha.1                                ...           7 years ago
  • 3.6.0                                ...           7 years ago
  • 3.5.0                                ...           7 years ago
  • 3.4.0                                ...           8 years ago
  • 3.3.0                                ...           8 years ago
  • 3.1.0                                ...           8 years ago
  • 3.0.1                                ...           8 years ago
  • 3.0.0                                ...           8 years ago
  • 3.0.0-beta-3                                ...           8 years ago
  • 3.0.0-beta-2                                ...           8 years ago
  • 3.0.0-beta-1                                ...           8 years ago
  • 2.53.3                                ...           8 years ago
  • 2.53.2                                ...           9 years ago
  • 2.53.1                                ...           9 years ago
  • 2.52.0                                ...           9 years ago
  • 2.48.2                                ...           9 years ago
  • 2.48.1                                ...           9 years ago
  • 2.48.0                                ...           9 years ago
  • 2.47.0                                ...           9 years ago
  • 2.46.1                                ...           9 years ago
  • 2.46.0                                ...           9 years ago
  • 2.45.1                                ...           10 years ago
  • 2.45.0                                ...           10 years ago
  • 2.44.0                                ...           10 years ago
  • 2.43.5                                ...           10 years ago
  • 2.43.4                                ...           10 years ago
  • 2.42.1                                ...           10 years ago
  • 2.42.0                                ...           10 years ago
  • 2.41.0                                ...           11 years ago
  • 2.40.0                                ...           11 years ago
  • 2.39.0                                ...           11 years ago
  • 2.38.1                                ...           11 years ago
  • 2.38.0                                ...           11 years ago
  • 2.37.0                                ...           11 years ago
  • 2.35.2                                ...           11 years ago
  • 2.35.1                                ...           11 years ago
  • 2.35.0                                ...           11 years ago
  • 2.34.1                                ...           11 years ago
  • 2.34.0                                ...           11 years ago
  • 2.33.0                                ...           11 years ago
  • 2.32.1                                ...           12 years ago
  • 2.32.0                                ...           12 years ago
  • 2.31.0                                ...           12 years ago
  • 2.30.0                                ...           12 years ago
  • 2.29.1                                ...           12 years ago
  • 2.29.0                                ...           12 years ago
Downloads
Total 92
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 5
Dependencies (4)
Dev Dependencies (12)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE