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

Update how repo downloads Chromedriver #182

Open
dequejenn opened this issue Apr 8, 2024 · 0 comments
Open

Update how repo downloads Chromedriver #182

dequejenn opened this issue Apr 8, 2024 · 0 comments
Assignees
Labels
next up Ticket is groomed for next sprint QA: none This ticket does not require QA signoff team-bass Bass team ticket

Comments

@dequejenn
Copy link

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

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"];
  }
}
@dequejenn dequejenn added next up Ticket is groomed for next sprint QA: none This ticket does not require QA signoff labels Apr 8, 2024
@dequejenn dequejenn added the team-bass Bass team ticket label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next up Ticket is groomed for next sprint QA: none This ticket does not require QA signoff team-bass Bass team ticket
Projects
None yet
Development

No branches or pull requests

2 participants