Skip to content

Commit bcd7705

Browse files
committed
fix(selenium): use Edge in IE mode for selenium IE
1 parent b914a44 commit bcd7705

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

selenium/createDriver.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@ import { Builder, Capabilities, logging } from "selenium-webdriver";
22
import Chrome from "selenium-webdriver/chrome.js";
33
import Edge from "selenium-webdriver/edge.js";
44
import Firefox from "selenium-webdriver/firefox.js";
5+
import IE from "selenium-webdriver/ie.js";
56
import { browserSupportsHeadless } from "../lib/getBrowserString.js";
67

78
// Set script timeout to 10min
89
const DRIVER_SCRIPT_TIMEOUT = 1000 * 60 * 10;
910

1011
export default async function createDriver( { browserName, headless, url, verbose } ) {
1112
const capabilities = Capabilities[ browserName ]();
12-
const prefs = new logging.Preferences();
13-
prefs.setLevel( logging.Type.BROWSER, logging.Level.ALL );
14-
capabilities.setLoggingPrefs( prefs );
13+
14+
// Support: IE 11+
15+
// When those are set for IE, the process crashes with an error:
16+
// "Unable to match capability set 0: goog:loggingPrefs is an unknown
17+
// extension capability for IE".
18+
if ( browserName !== "ie" ) {
19+
const prefs = new logging.Preferences();
20+
prefs.setLevel( logging.Type.BROWSER, logging.Level.ALL );
21+
capabilities.setLoggingPrefs( prefs );
22+
}
1523

1624
let driver = new Builder().withCapabilities( capabilities );
1725

@@ -49,6 +57,10 @@ export default async function createDriver( { browserName, headless, url, verbos
4957
edgeOptions.setEdgeChromiumBinaryPath( process.env.EDGE_BIN );
5058
}
5159

60+
const ieOptions = new IE.Options();
61+
ieOptions.setEdgeChromium( true );
62+
ieOptions.setEdgePath( "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" );
63+
5264
if ( headless ) {
5365
chromeOptions.addArguments( "--headless=new" );
5466
firefoxOptions.addArguments( "--headless" );
@@ -65,6 +77,7 @@ export default async function createDriver( { browserName, headless, url, verbos
6577
.setChromeOptions( chromeOptions )
6678
.setFirefoxOptions( firefoxOptions )
6779
.setEdgeOptions( edgeOptions )
80+
.setIeOptions( ieOptions )
6881
.build();
6982

7083
if ( verbose ) {

0 commit comments

Comments
 (0)