@@ -47,17 +47,16 @@ import { Browsers } from './browsers';
4747
4848const throttleOption : string = process . env . TEST_THROTTLE_NETWORK as string ;
4949const headlessBrowser : string = process . env . TEST_BROWSER_HEADLESS as string ;
50+ const browserBinaryPath : string = process . env . TEST_BROWSER_BINARY_PATH as string ;
5051const remoteDebug : string = process . env . TEST_REMOTE_DEBUG as string ;
5152const certValidation : string = process . env . NODE_TLS_REJECT_UNAUTHORIZED as string ;
5253const SECOND = 1000 ;
5354const MINUTE = 60 * SECOND ;
5455const NO_QUEUE_COMMANDS = [ 'getLog' , 'getStatus' , 'newSession' , 'quit' ] ;
5556const downloadDir = resolve ( REPO_ROOT , 'target/functional-tests/downloads' ) ;
5657const chromiumDownloadPrefs = {
57- prefs : {
58- 'download.default_directory' : downloadDir ,
59- 'download.prompt_for_download' : false ,
60- } ,
58+ 'download.default_directory' : downloadDir ,
59+ 'download.prompt_for_download' : false ,
6160} ;
6261
6362/**
@@ -93,8 +92,8 @@ async function attemptToCreateCommand(
9392 const buildDriverInstance = async ( ) => {
9493 switch ( browserType ) {
9594 case 'chrome' : {
96- const chromeCapabilities = Capabilities . chrome ( ) ;
97- const chromeOptions = [
95+ const chromeOptions = new chrome . Options ( ) ;
96+ chromeOptions . addArguments (
9897 // Disables the sandbox for all process types that are normally sandboxed.
9998 'no-sandbox' ,
10099 // Launches URL in new browser window.
@@ -104,47 +103,55 @@ async function attemptToCreateCommand(
104103 // Use fake device for Media Stream to replace actual camera and microphone.
105104 'use-fake-device-for-media-stream' ,
106105 // Bypass the media stream infobar by selecting the default device for media streams (e.g. WebRTC). Works with --use-fake-device-for-media-stream.
107- 'use-fake-ui-for-media-stream' ,
108- ] ;
106+ 'use-fake-ui-for-media-stream'
107+ ) ;
108+
109109 if ( process . platform === 'linux' ) {
110110 // The /dev/shm partition is too small in certain VM environments, causing
111111 // Chrome to fail or crash. Use this flag to work-around this issue
112112 // (a temporary directory will always be used to create anonymous shared memory files).
113- chromeOptions . push ( 'disable-dev-shm-usage' ) ;
113+ chromeOptions . addArguments ( 'disable-dev-shm-usage' ) ;
114114 }
115+
115116 if ( headlessBrowser === '1' ) {
116117 // Use --disable-gpu to avoid an error from a missing Mesa library, as per
117118 // See: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
118- chromeOptions . push ( 'headless' , 'disable-gpu' ) ;
119+ chromeOptions . headless ( ) ;
120+ chromeOptions . addArguments ( 'disable-gpu' ) ;
119121 }
122+
120123 if ( certValidation === '0' ) {
121- chromeOptions . push ( 'ignore-certificate-errors' ) ;
124+ chromeOptions . addArguments ( 'ignore-certificate-errors' ) ;
122125 }
123126
124127 if ( remoteDebug === '1' ) {
125128 // Visit chrome://inspect in chrome to remotely view/debug
126- chromeOptions . push ( 'headless' , 'disable-gpu' , 'remote-debugging-port=9222' ) ;
129+ chromeOptions . headless ( ) ;
130+ chromeOptions . addArguments ( 'disable-gpu' , 'remote-debugging-port=9222' ) ;
127131 }
128- chromeCapabilities . set ( 'goog:chromeOptions' , {
129- w3c : true ,
130- args : chromeOptions ,
131- ...chromiumDownloadPrefs ,
132- } ) ;
133- chromeCapabilities . set ( 'unexpectedAlertBehaviour' , 'accept' ) ;
134- chromeCapabilities . set ( 'goog:loggingPrefs' , { browser : 'ALL' } ) ;
135- chromeCapabilities . setAcceptInsecureCerts ( config . acceptInsecureCerts ) ;
132+
133+ if ( browserBinaryPath ) {
134+ chromeOptions . setChromeBinaryPath ( browserBinaryPath ) ;
135+ }
136+
137+ const prefs = new logging . Preferences ( ) ;
138+ prefs . setLevel ( logging . Type . BROWSER , logging . Level . ALL ) ;
139+ chromeOptions . setUserPreferences ( chromiumDownloadPrefs ) ;
140+ chromeOptions . setLoggingPrefs ( prefs ) ;
141+ chromeOptions . set ( 'unexpectedAlertBehaviour' , 'accept' ) ;
142+ chromeOptions . setAcceptInsecureCerts ( config . acceptInsecureCerts ) ;
136143
137144 let session ;
138145 if ( remoteSessionUrl ) {
139146 session = await new Builder ( )
140147 . forBrowser ( browserType )
141- . withCapabilities ( chromeCapabilities )
148+ . setChromeOptions ( chromeOptions )
142149 . usingServer ( remoteSessionUrl )
143150 . build ( ) ;
144151 } else {
145152 session = await new Builder ( )
146153 . forBrowser ( browserType )
147- . withCapabilities ( chromeCapabilities )
154+ . setChromeOptions ( chromeOptions )
148155 . setChromeService ( new chrome . ServiceBuilder ( chromeDriver . path ) . enableVerboseLogging ( ) )
149156 . build ( ) ;
150157 }
@@ -179,7 +186,7 @@ async function attemptToCreateCommand(
179186 edgeOptions . setBinaryPath ( edgePaths . browserPath ) ;
180187 const options = edgeOptions . get ( 'ms:edgeOptions' ) ;
181188 // overriding options to include preferences
182- Object . assign ( options , chromiumDownloadPrefs ) ;
189+ Object . assign ( options , { prefs : chromiumDownloadPrefs } ) ;
183190 edgeOptions . set ( 'ms:edgeOptions' , options ) ;
184191 const session = await new Builder ( )
185192 . forBrowser ( 'MicrosoftEdge' )
0 commit comments