axe-core-gems
axe-core-gems copied to clipboard
Update how repo downloads Chromedriver
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
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
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)
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']
require 'dotenv'
Dotenv.load(File.join(Dir.home, '.browser-driver-manager', '.env'))
chromedriver_path = ENV['CHROMEDRIVER_TEST_PATH']
chrome_path = ENV['CHROME_TEST_PATH']
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<String, String> env = new HashMap<String, String>();
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");
}
}
using System;
using System.IO;
using System.Collections.Generic;
class GetChromePath
{
static void Main()
{
Dictionary<string, string> env = new Dictionary<string, string>();
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"];
}
}