dequelabs / dequelabs/axe-devhub-action
Update how repo downloads Chromedriver
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Epic https://github.com/dequelabs/axe-api-team/issues/497
Proposal: https://github.com/dequelabs/axe-api-team/blob/ac01e14fc119965e2ccb4bd834a5554cedb275dd/proposals/technical-requirements/chrome-driver-download-steps-in-central-place.md
### Upgrade version of `browser-driver-manager` in each repository CI configuration
`browser-driver-manager` should upgrade its version so that the repos can use the new chrome driver installation method.
## Update repos that downloads `chromedriver`
Each repo that downloads `chromedriver` will need to do it using `browser-driver-manager`
Please reference [Usage guide](https://www.npmjs.com/package/browser-driver-manager#usage)
## Usage
When using this chromedriver path in the tests, you can use the following code to get the path of the chromedriver:
## Getting the path of chromedriver
To be able to get the path of where chromedriver exist in non-node libraries each library can read the `.env` file created by `browser-driver-manager` and get the path from there.
### NPM based packages
```javascript
const { config } = require('dotenv')
const os = require('os')
const path = require('path')
const HOME_DIR = os.homedir()
const BDM_CACHE_DIR = path.resolve(HOME_DIR, '.browser-driver-manager')
config({ path: path.resolve(BDM_CACHE_DIR, '.env') })
const { CHROMEDRIVER_TEST_PATH, CHROME_TEST_PATH } = process.env
```
### Non-NPM based packages (Psuedo code)
```python
from os import path
from dotenv import dotenv_values
env = dotenv_values(path.join(path.expanduser('~'), '.browser-driver-manager', '.env'))
chromedriver_path = env['CHROMEDRIVER_TEST_PATH']
chrome_path = env['CHROME_TEST_PATH']
```
```ruby
require 'dotenv'
Dotenv.load(File.join(Dir.home, '.browser-driver-manager', '.env'))
chromedriver_path = ENV['CHROMEDRIVER_TEST_PATH']
chrome_path = ENV['CHROME_TEST_PATH']
```
```java
import java.util.Map;
import java.util.HashMap;
import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
public class GetChromePath {
public static void main(String[] args) {
Map env = new HashMap();
try {
BufferedReader reader = new BufferedReader(new FileReader(new File(System.getProperty("user.home") + "/.browser-driver-manager/.env")));
String line;
while ((line = reader.readLine()) != null) {
String[] parts = line.split("=");
env.put(parts[0], parts[1]);
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
String chromedriverPath = env.get("CHROMEDRIVER_TEST_PATH");
String chromePath = env.get("CHROME_TEST_PATH");
}
}
```
```csharp
using System;
using System.IO;
using System.Collections.Generic;
class GetChromePath
{
static void Main()
{
Dictionary env = new Dictionary();
using (StreamReader reader = new StreamReader(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".browser-driver-manager", ".env")))
{
string line;
while ((line = reader.ReadLine()) != null)
{
string[] parts = line.Split("=");
env.Add(parts[0], parts[1]);
}
}
string chromedriverPath = env["CHROMEDRIVER_TEST_PATH"];
string chromePath = env["CHROME_TEST_PATH"];
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.