Skip to content

Commit ad643b7

Browse files
committed
fix(createDriver): set default IEDriver location in GH Actions
1 parent 5c50f77 commit ad643b7

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

selenium/createDriver.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,28 @@ export default async function createDriver( { browserName, headless, url, verbos
5757

5858
const ieOptions = new IE.Options();
5959
ieOptions.setEdgeChromium( true );
60-
ieOptions.setEdgePath( "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" );
60+
ieOptions.setEdgePath( "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe" );
61+
62+
// Set IEDriver path from environment variable or GitHub Actions default
63+
let ieService;
64+
let ieDriverPath = process.env.IEWEBDRIVER;
65+
if ( !ieDriverPath && process.env.GITHUB_ACTIONS ) {
66+
67+
// The default in GitHub Actions Windows runners
68+
ieDriverPath = "C:\\SeleniumWebDrivers\\IEDriver";
69+
}
70+
71+
if ( ieDriverPath ) {
72+
73+
// Append the executable name if only a directory was provided
74+
if ( !ieDriverPath.endsWith( ".exe" ) ) {
75+
ieDriverPath = `${ ieDriverPath }\\IEDriverServer.exe`;
76+
}
77+
if ( verbose ) {
78+
console.log( `Setting IEDriver path to ${ ieDriverPath }` );
79+
}
80+
ieService = new IE.ServiceBuilder( ieDriverPath );
81+
}
6182

6283
if ( headless ) {
6384
chromeOptions.addArguments( "--headless=new" );
@@ -71,12 +92,17 @@ export default async function createDriver( { browserName, headless, url, verbos
7192
}
7293
}
7394

74-
const driver = new Builder().withCapabilities( capabilities )
95+
const builder = new Builder().withCapabilities( capabilities )
7596
.setChromeOptions( chromeOptions )
7697
.setFirefoxOptions( firefoxOptions )
7798
.setEdgeOptions( edgeOptions )
78-
.setIeOptions( ieOptions )
79-
.build();
99+
.setIeOptions( ieOptions );
100+
101+
if ( ieService ) {
102+
builder.setIeService( ieService );
103+
}
104+
105+
const driver = builder.build();
80106

81107
if ( verbose ) {
82108
const driverCapabilities = await driver.getCapabilities();

0 commit comments

Comments
 (0)