You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42-9Lines changed: 42 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ So instead you decided to pin to the `@latest` tag. This works great as now both
29
29
30
30
This is why this package exists. It will help keep the versions of Chrome and ChromeDriver in-sync so that your continuous integration system tests don't fail due to ChromeDriver versions.
31
31
32
-
So now instead of relying on pinning, you can ask the system which version of Chrome is installed and always get the version of ChromeDriver that matches. This will even work for Chrome channels that are not just Stable (i.e. Beta, Dev, and Canary).
32
+
So now instead of relying on pinning, you can install the desired version of Chrome and Chromedriver. This will even work for Chrome channels that are not just Stable (i.e. Beta, Dev, and Canary).
33
33
34
34
Here's an example of doing just that in an npm script.
35
35
@@ -46,22 +46,52 @@ If you wanted to install Chrome Beta and its associated driver:
Once installed, a directory is created in your home directory called `.browser-driver-manager`. The directory will contain a `.env` file which will list the install path of both Chrome and Chromedriver under `CHROME_TEST_PATH` and `CHROMEDRIVER_TEST_PATH` respectively.
55
+
56
+
```
57
+
# ~/.browser-driver-manager/.env
58
+
CHROME_TEST_PATH=".browser-driver-manager/chrome/mac_arm-125.0.6422.141/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"
To use the Chrome or Chromedriver binaries, you'll have to read the contents of the file and grab the path to the desired path. For example, using [dotenv](https://www.npmjs.com/package/dotenv) you can do the following:
V1 use to detect the version of Chrome installed on the system and install the corresponding version of the [chromedriver npm package](https://www.npmjs.com/package/chromedriver). However this had problems as the chromedriver package wasn't always up-to-date with the latest version so when Chrome updated to the next version, the chromedriver package could lag behind and still cause out-of-sync issues. Additionally the chromedriver package didn't always have the latest versions of non-stable channels so asking for Chrome Canary wasn't always reliable.
71
+
72
+
V2 uses the newly released [Chrome for Testing](https://developer.chrome.com/blog/chrome-for-testing) to manage Chrome. This enables both installing specific versions of Chrome and fixes the previous chromedriver package issue. V2 utilizes the [`puppeteer/browser`](https://pptr.dev/browsers-api) script to manage the installation of Chrome and Chromedriver as it can handle downloading the binaries (and the multiple changes to the chromedriver download URL). This means that v2 no longer uses the chromedriver npm package to get chromedriver.
73
+
74
+
This means in v2 you'll need to grab the Chromedriver path from the `~/.browser-driver-manager/.env` file and not from the chromedriver npm package. Additionally, you'll need to grab the Chrome path pass the path to any browser driver, such as Webdriver.
75
+
76
+
Here's an example of grabbing the Chromedriver path in v1 and the change for v2.
console.log('CHROME_TEST_PATH is set in',chromePath);
81
-
console.log('CHROMEDRIVER_TEST_PATH is set in',chromedriverPath);
82
-
console.log('VERSION:',version);
83
83
}catch(e){
84
84
thrownewErrorWithSuggestion(
85
85
`Error setting CHROME/CHROMEDRIVER_TEST_PATH/VERSION. Ensure that the environment file at ${envPath} is writable.`,
@@ -121,7 +121,7 @@ async function which() {
121
121
* @throws {Error} - Environment file must have valid version.
122
122
*/
123
123
asyncfunctiongetVersion(suppressErrors=false){
124
-
constpattern=/^VERSION="([\d.]+)"$/m;
124
+
constpattern=/^CHROME_TEST_VERSION="([\d.]+)"$/m;
125
125
constenv=awaitgetEnv();
126
126
127
127
if(!env){
@@ -139,7 +139,7 @@ async function getVersion(suppressErrors = false) {
139
139
returnnull;
140
140
}
141
141
thrownewError(
142
-
`No version found in the environment file. Either remove the environment file and reinstall, or add a line 'VERSION={YOUR_INSTALLED_VERSION} to it.`
142
+
`No version found in the environment file. Either remove the environment file and reinstall, or add a line 'CHROME_TEST_VERSION={YOUR_INSTALLED_VERSION} to it.`
0 commit comments