@@ -385,6 +385,62 @@ const LocalWebDriverFirefoxHeadless = generateSubclass(
385385 } ,
386386 } ) ;
387387
388+ // Opera binary detection
389+ const operaOptions = { } ;
390+ let operaBinary = which . sync ( 'opera' , { nothrow : true } ) ;
391+
392+ const operaPaths = {
393+ darwin : [
394+ '/Applications/Opera.app/Contents/MacOS/Opera' ,
395+ '/Applications/Opera Stable.app/Contents/MacOS/Opera' ,
396+ ] ,
397+ win32 : [
398+ 'C:\\Program Files\\Opera\\opera.exe' ,
399+ 'C:\\Program Files (x86)\\Opera\\opera.exe' ,
400+ `C:\\Users\\${ os . userInfo ( ) . username } \\AppData\\Local\\Programs\\Opera\\opera.exe` ,
401+ ] ,
402+ linux : [
403+ '/snap/bin/opera' ,
404+ '/usr/bin/opera' ,
405+ ] ,
406+ } ;
407+
408+ if ( ! operaBinary && operaPaths [ os . platform ( ) ] ) {
409+ for ( const p of operaPaths [ os . platform ( ) ] ) {
410+ if ( fs . existsSync ( p ) ) {
411+ operaBinary = p ;
412+ break ;
413+ }
414+ }
415+ }
416+
417+ if ( operaBinary ) {
418+ operaOptions [ 'goog:chromeOptions' ] = {
419+ binary : operaBinary ,
420+ } ;
421+ }
422+
423+ const LocalWebDriverOpera = generateSubclass (
424+ 'Opera' , 'Opera' ,
425+ 'operadriver' ,
426+ ( port ) => [ '--port=' + port ] ,
427+ operaOptions ) ;
428+
429+ const LocalWebDriverOperaHeadless = generateSubclass (
430+ 'Opera' , 'OperaHeadless' ,
431+ 'operadriver' ,
432+ ( port ) => [ '--port=' + port ] ,
433+ mergeOptions ( operaOptions , {
434+ 'goog:chromeOptions' : {
435+ args : [
436+ '--headless' ,
437+ '--no-sandbox' ,
438+ '--disable-gpu' ,
439+ '--disable-dev-shm-usage' ,
440+ ] ,
441+ } ,
442+ } ) ) ;
443+
388444const LocalWebDriverSafari = generateSafariDriver ( 'Safari' ) ;
389445
390446const LocalWebDriverSafariIOS = generateSafariDriver ( 'SafariIOS' , 'iPhone' ) ;
@@ -407,6 +463,8 @@ module.exports = {
407463 'launcher:EdgeHeadless' : [ 'type' , LocalWebDriverEdgeHeadless ] ,
408464 'launcher:Firefox' : [ 'type' , LocalWebDriverFirefox ] ,
409465 'launcher:FirefoxHeadless' : [ 'type' , LocalWebDriverFirefoxHeadless ] ,
466+ 'launcher:Opera' : [ 'type' , LocalWebDriverOpera ] ,
467+ 'launcher:OperaHeadless' : [ 'type' , LocalWebDriverOperaHeadless ] ,
410468} ;
411469
412470// Safari is only supported on Mac.
0 commit comments