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

[Follow-up] Restore checking for TEST_BROWSER_BINARY_PATH logic in scripts/upgrade_chromedriver.js #4147

Open
ananzh opened this issue May 26, 2023 · 0 comments

Comments

@ananzh
Copy link
Member

ananzh commented May 26, 2023

Issue Description

In #4071, we changed

switch (process.platform) {
  case 'win32':
    versionCheckCommands.push(
      ...[
        ...(process.env.TEST_BROWSER_BINARY_PATH
          ? [
              `powershell "(Get-Item \\"${process.env.TEST_BROWSER_BINARY_PATH}\\").VersionInfo.FileVersion"`,
            ]
          : []),
        'powershell "(Get-Item \\"$Env:Programfiles/Google/Chrome/Application/chrome.exe\\").VersionInfo.FileVersion"',
      ]
    );
    break;

  case 'darwin':
    versionCheckCommands.push(
      ...[
        ...(process.env.TEST_BROWSER_BINARY_PATH
          ? [`${process.env.TEST_BROWSER_BINARY_PATH} --version`]
          : []),
        '/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --version',
      ]
    );
    break;

  default:
    versionCheckCommands.push(
      ...(process.env.TEST_BROWSER_BINARY_PATH
        ? [`${process.env.TEST_BROWSER_BINARY_PATH} --version`]
        : [])
    );
    versionCheckCommands.push(
      ...[
        '/usr/bin',
        '/usr/local/bin',
        '/usr/sbin',
        '/usr/local/sbin',
        '/opt/bin',
        '/usr/bin/X11',
        '/usr/X11R6/bin',
      ].flatMap((loc) =>
        [
          'google-chrome --version',
          'google-chrome-stable --version',
          'chromium --version',
          'chromium-browser --version',
        ].map((cmd) => `${loc}/${cmd}`)
      )
    );
}

to

switch (process.platform) {
  case 'win32':
    versionCheckCommands.push(
      'powershell "(Get-Item \\"$Env:Programfiles/Google/Chrome/Application/chrome.exe\\").VersionInfo.FileVersion"'
    );
    break;

  case 'darwin':
    versionCheckCommands.push(
      '/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --version'
    );
    break;

  default:
    versionCheckCommands.push(
      ...[
        '/usr/bin',
        '/usr/local/bin',
        '/usr/sbin',
        '/usr/local/sbin',
        '/opt/bin',
        '/usr/bin/X11',
        '/usr/X11R6/bin',
      ].flatMap((loc) =>
        [
          'google-chrome --version',
          'google-chrome-stable --version',
          'chromium --version',
          'chromium-browser --version',
        ].map((cmd) => `${loc}/${cmd}`)
      )
    );
}

to get workflow to work with node 14. This is a temp fix. With the check for TEST_BROWSER_BINARY_PATH, we can specify a custom path for the browser binary. This can be very useful for testing different browser versions or browser types without having to change the hardcoded paths in your script.

We need to follow up and modify this part after Node 18 PR merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant