Skip to content

Commit

Permalink
Run prettifier over the selenium-webdriver node code
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Mar 8, 2024
1 parent 832a31e commit ffedae3
Show file tree
Hide file tree
Showing 32 changed files with 882 additions and 648 deletions.
11 changes: 2 additions & 9 deletions javascript/node/selenium-webdriver/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@ module.exports = {
node: true,
es6: true,
},
extends: [
'eslint:recommended',
'plugin:node/recommended',
'plugin:prettier/recommended',
],
extends: ['eslint:recommended', 'plugin:node/recommended', 'plugin:prettier/recommended'],
parserOptions: {
ecmaVersion: 2022,
},
ignorePatterns: [
'.eslintrc.js',
'.prettierrc',
],
ignorePatterns: ['.eslintrc.js', '.prettierrc'],
plugins: ['no-only-tests'],
rules: {
'no-const-assign': 'error',
Expand Down
864 changes: 523 additions & 341 deletions javascript/node/selenium-webdriver/CHANGES.md

Large diffs are not rendered by default.

103 changes: 57 additions & 46 deletions javascript/node/selenium-webdriver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ Selenium may be installed via npm with
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,
[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)][chrome] |
| Internet Explorer | [IEDriverServer.exe][release] |
| Edge | [MicrosoftWebDriver.msi][edge] |
| Firefox | [geckodriver(.exe)][geckodriver] |
| Opera | [operadriver(.exe)][operadriver] |
| Safari | [safaridriver] |
| Browser | Component |
|:------------------|:---------------------------------|
| Chrome | [chromedriver(.exe)][chrome] |
| Internet Explorer | [IEDriverServer.exe][release] |
| Edge | [MicrosoftWebDriver.msi][edge] |
| Firefox | [geckodriver(.exe)][geckodriver] |
| Opera | [operadriver(.exe)][operadriver] |
| Safari | [safaridriver] |

## Usage

Expand Down Expand Up @@ -103,6 +102,7 @@ let driver = new webdriver.Builder()
.usingServer('http://localhost:4444/wd/hub')
.build();
```

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

Expand Down Expand Up @@ -135,43 +135,44 @@ 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,
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_ |
| 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.
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.
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.
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 |
| 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

Expand All @@ -180,52 +181,62 @@ the issue tracker

- __Do__ include a detailed description of the problem.
- __Do__ include a link to a [gist](http://gist.github.com/) with any
interesting stack traces/logs (you may also attach these directly to the bug
report).
interesting stack traces/logs (you may also attach these directly to the bug
report).
- __Do__ include a [reduced test case][reduction]. 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.
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][users] or #selenium IRC
channel.
inquiries should be directed to the [user forum][users] 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.
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.
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
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The SFC licenses this file
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
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
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

[LTS]: https://github.com/nodejs/LTS

[PATH]: http://en.wikipedia.org/wiki/PATH_%28variable%29

[api]: http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/

[chrome]: http://chromedriver.storage.googleapis.com/index.html

[gh]: https://github.com/SeleniumHQ/selenium/

[issues]: https://github.com/SeleniumHQ/selenium/issues

[edge]: http://go.microsoft.com/fwlink/?LinkId=619687

[geckodriver]: https://github.com/mozilla/geckodriver/releases/

[reduction]: http://www.webkit.org/quality/reduction.html

[release]: https://www.selenium.dev/downloads/

[users]: https://groups.google.com/forum/#!forum/selenium-users

[safaridriver]: https://developer.apple.com/library/prerelease/content/releasenotes/General/WhatsNewInSafari/Articles/Safari_10_0.html#//apple_ref/doc/uid/TP40014305-CH11-DontLinkElementID_28

[operadriver]: https://github.com/operasoftware/operachromiumdriver/releases
80 changes: 37 additions & 43 deletions javascript/node/selenium-webdriver/bidi/addInterceptParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,72 +15,66 @@
// specific language governing permissions and limitations
// under the License.

const {UrlPattern} = require("./urlPattern");
const { UrlPattern } = require('./urlPattern')

class AddInterceptParameters {
#phases = []
#urlPatterns = []

constructor(phases) {
if (phases instanceof Array) {
phases.forEach(phase => this.#phases.push(phase))
phases.forEach((phase) => this.#phases.push(phase))
} else {
this.#phases.push(phases)
}
}

urlPattern(pattern)
{
urlPattern(pattern) {
if (!pattern instanceof UrlPattern) {
throw new Error(`Pattern must be an instance of UrlPattern. Received: '${pattern})'`)
}
this.#urlPatterns.push(Object.fromEntries(pattern.asMap()))
return this
}

urlPatterns(patterns) {
patterns.forEach((pattern) => {
if (!pattern instanceof UrlPattern) {
throw new Error(`Pattern must be an instance of UrlPattern. Received: '${pattern})'`)
throw new Error(`Pattern must be an instance of UrlPattern. Received:'${pattern}'`)
}
this.#urlPatterns.push(Object.fromEntries(pattern.asMap()))
return this
}
})
return this
}

urlPatterns(patterns)
{
patterns.forEach(pattern => {
if (!pattern instanceof UrlPattern) {
throw new Error(`Pattern must be an instance of UrlPattern. Received:'${pattern}'`)
}
this.#urlPatterns.push(Object.fromEntries(pattern.asMap()))
})
return this
urlStringPattern(pattern) {
if (!pattern instanceof String) {
throw new Error(`Pattern must be an instance of String. Received:'${pattern}'`)
}

urlStringPattern(pattern)
{
this.#urlPatterns.push({ type: 'string', pattern: pattern })
return this
}

urlStringPatterns(patterns) {
patterns.forEach((pattern) => {
if (!pattern instanceof String) {
throw new Error(`Pattern must be an instance of String. Received:'${pattern}'`)
}
this.#urlPatterns.push({ type: 'string', pattern: pattern })
})
return this
}

this.#urlPatterns.push({'type': 'string', 'pattern': pattern})
return this
}

urlStringPatterns(patterns)
{
patterns.forEach(pattern => {
if (!pattern instanceof String) {
throw new Error(`Pattern must be an instance of String. Received:'${pattern}'`)
}
this.#urlPatterns.push({'type': 'string', 'pattern': pattern})
})
return this
asMap() {
const map = new Map()
map.set('phases', this.#phases)
if (this.#urlPatterns.length > 0) {
map.set('urlPatterns', this.#urlPatterns)
}


asMap()
{
const map = new Map()
map.set('phases', this.#phases)
if (this.#urlPatterns.length > 0) {
map.set('urlPatterns', this.#urlPatterns)
}

return map
}
return map
}
}

module.exports = {AddInterceptParameters}
module.exports = { AddInterceptParameters }
1 change: 1 addition & 0 deletions javascript/node/selenium-webdriver/bidi/argumentValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

const { LocalValue } = require('./protocolValue')

class ArgumentValue {
constructor(value) {
this.value = value
Expand Down
14 changes: 7 additions & 7 deletions javascript/node/selenium-webdriver/bidi/browsingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ class BrowsingContext {
this._driver = driver
}

/**
* @returns id
*/
get id() {
return this._id
}

async init({ browsingContextId, type, referenceContext }) {
if (!(await this._driver.getCapabilities()).get('webSocketUrl')) {
throw Error('WebDriver instance must support BiDi protocol')
Expand Down Expand Up @@ -101,13 +108,6 @@ class BrowsingContext {
return await this.bidi.send(params)
}

/**
* @returns id
*/
get id() {
return this._id
}

/**
* @param url the url to navigate to
* @param readinessState type of readiness state: "none" / "interactive" / "complete"
Expand Down
Loading

0 comments on commit ffedae3

Please sign in to comment.