Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add install-chromedriver command #366

Merged
merged 20 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
"rules": {
"func-names": "off"
}
},
{
"files": "scripts/**/*",
"parserOptions": {"sourceType": "module"},
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
]
}
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ this driver supports the following:
> **Note**
> `msedgedriver` support is limited. `appium:autodownloadEnabled` does not work for the driver, thus `appium:executable` is necessary to automate MSEdge browser properly.

## Scripts

### install-chromedriver

This script is used to install the given or latest stable version of chromedriver (113+) from
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
[Chrome for testing](https://github.com/GoogleChromeLabs/chrome-for-testing)
with `appium driver run chromium install-chromedriver`.

Below environment arguments are available:
- `CHROMEDRIVER_EXECUTABLE_DIR`
- Let the command to download chromedrivers in the given directory. Once you set `appium:executableDir` to the same directory, a new session will refer to the same directory. Defaults to `node_modules/appium-chromedriver/chromedriver` in `appium-chromium-driver` package.
KazuCocoa marked this conversation as resolved.
Show resolved Hide resolved
- `CHROMEDRIVER_EXECUTABLE_DIR=/tmp/chromedrivers appium driver run chromium install-chromedriver`
- `CHROMEDRIVER_VERSION`
- Let the command download a specific version.
- i.e. `CHROMEDRIVER_VERSION=131.0.6778.3 appium driver run chromium install-chromedriver`
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
- `CHROMELABS_URL`
- Let the command get the list of available chromedrivers from instead of the default `https://googlechromelabs.github.io`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the given mirror instead of the default one


## Contributing

Contributions to this project are welcome! Feel free to submit a PR on GitHub.
Expand Down
13 changes: 6 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"README.md",
"CHANGELOG.md",
"LICENSE",
"npm-shrinkwrap.json"
"npm-shrinkwrap.json",
"scripts"
],
"scripts": {
"build": "tsc -b",
Expand All @@ -56,7 +57,7 @@
"singleQuote": true
},
"dependencies": {
"appium-chromedriver": "6.0.8",
"appium-chromedriver": "^6.1.0",
"bluebird": "3.7.2",
"lodash": "4.17.21"
},
Expand All @@ -80,7 +81,10 @@
"macOS",
"Linux"
],
"mainClass": "ChromiumDriver"
"mainClass": "ChromiumDriver",
"scripts": {
"install-chromedriver": "./scripts/install-chromedriver.mjs"
}
},
"typedoc": {
"entryPoint": "./build/lib/index.js"
Expand Down
21 changes: 21 additions & 0 deletions scripts/install-chromedriver.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ChromedriverStorageClient } from 'appium-chromedriver';

function getChromedriverVersion() {
return process.env.CHROMEDRIVER_VERSION;
}

function getExecutableDir() {
return process.env.CHROMEDRIVER_EXECUTABLE_DIR;
}

async function install () {
const client = new ChromedriverStorageClient({
chromedriverDir: getExecutableDir(),
});
const chromeDriverVersion = getChromedriverVersion() || await client.getLatestKnownGoodVersion();
KazuCocoa marked this conversation as resolved.
Show resolved Hide resolved
await client.syncDrivers({
versions: [chromeDriverVersion],
});
}

(async () => await install())();
Loading