Skip to content

Commit

Permalink
fix: Pick a default Edge binary location on all platforms (shaka-proj…
Browse files Browse the repository at this point in the history
…ect#65)

Since v120 or v121, msedgedriver always fails if you do not specify the
Edge binary path. By assuming some platform-specific defaults, we can
fix local testing on Edge in most cases.
  • Loading branch information
joeyparrish authored Feb 6, 2024
1 parent f5442d4 commit 17069e7
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,30 @@ const LocalWebDriverChromeHeadless = generateSubclass(
// that explicitly. This works around the following edgedriver bug:
// https://github.com/MicrosoftEdge/EdgeWebDriver/issues/102#issuecomment-1710724173
const edgeOptions = {};
const edgeBinary = which.sync('microsoft-edge', {nothrow: true});
let edgeBinary = which.sync('microsoft-edge', {nothrow: true});

if (!edgeBinary) {
// Since v120 or v121, msedgedriver always fails if you do not specify the
// Edge binary path. Assume some platform-specific defaults. Only use these
// paths if they exist.
switch (os.platform()) {
case 'darwin':
edgeBinary = '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge';
break;
case 'win32':
edgeBinary = 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe';
break;
case 'linux':
edgeBinary = '/opt/microsoft/msedge/microsoft-edge';
break;
}

// If that platform-specific binary doesn't exist, don't try to use it.
if (edgeBinary && !fs.existsSync(edgeBinary)) {
edgeBinary = null;
}
}

if (edgeBinary) {
edgeOptions['ms:edgeOptions'] = {
binary: edgeBinary,
Expand Down

0 comments on commit 17069e7

Please sign in to comment.