@@ -36,9 +36,14 @@ main()
36
36
37
37
async function main ( ) {
38
38
console . log ( 'Starting webdriver backend' )
39
- await startWebdriverBackend ( { driver : 'chrome' } )
39
+ const { proc, success} = await startWebdriverBackend ( { driver : 'chrome' } )
40
+ if ( ! success ) {
41
+ console . error ( 'Failed to start webdriver backend' )
42
+ console . error ( proc . error )
43
+ return
44
+ }
40
45
const sideFiles = args . filter ( ( arg ) => arg . endsWith ( '.side' ) )
41
- for ( const sideFile of sideFiles ) {
46
+ for ( const sideFile of [ sideFiles [ 0 ] ] ) {
42
47
console . log ( 'Starting driver for sidefile' , sideFile )
43
48
const driver = await new webdriver . Builder ( )
44
49
. usingServer ( `http://localhost:${ port } ` )
@@ -48,8 +53,9 @@ async function main() {
48
53
binary : electronBinaryPath ,
49
54
args : [
50
55
'app=' + pathToSeleniumIDE ,
51
- `side-file=./../../ ${ sideFile . replace ( './' , '' ) } ` ,
56
+ `side-file=${ sideFile } ` ,
52
57
] ,
58
+ excludeSwitches : [ 'enable-logging' ] ,
53
59
} ,
54
60
} )
55
61
. forBrowser ( 'chrome' ) // note: use .forBrowser('electron') for selenium-webdriver <= 3.6.0
@@ -58,6 +64,7 @@ async function main() {
58
64
await driver . quit ( )
59
65
return
60
66
}
67
+ proc . kill ( )
61
68
}
62
69
63
70
function startWebdriverBackend ( ) {
@@ -66,31 +73,33 @@ function startWebdriverBackend() {
66
73
let initialized = false
67
74
const args = [ '--verbose' , `--port=${ port } ` ]
68
75
if ( fs . existsSync ( driverPath ) ) {
69
- const driver = spawn ( driverPath . replace ( / \s / g, ' ' ) , args , {
76
+ const proc = spawn ( driverPath . replace ( / \s / g, ' ' ) , args , {
70
77
env : { } ,
71
78
shell : false ,
72
79
} )
73
80
process . on ( 'exit' , ( ) => {
74
- driver . kill ( )
81
+ if ( ! proc . killed ) {
82
+ proc . kill ( )
83
+ }
75
84
} )
76
- driver . stdout . on ( 'data' , ( out ) => {
85
+ proc . stdout . on ( 'data' , ( out ) => {
77
86
const outStr = `${ out } `
78
87
WebdriverDebugLog ( outStr )
79
88
const fullyStarted = outStr . includes ( successMessage )
80
89
if ( fullyStarted ) {
81
90
initialized = true
82
91
WebdriverDebugLog ( 'Driver has initialized!' )
83
- resolve ( { success : true , driver : driver } )
92
+ resolve ( { success : true , proc : proc } )
84
93
}
85
94
} )
86
- driver . stderr . on ( 'data' , ( err ) => {
95
+ proc . stderr . on ( 'data' , ( err ) => {
87
96
const errStr = `${ err } `
88
97
WebdriverDebugLog ( errStr )
89
98
if ( ! initialized ) {
90
99
resolve ( { success : false , error : errStr } )
91
100
}
92
101
} )
93
- driver . on ( 'close' , ( code ) => {
102
+ proc . on ( 'close' , ( code ) => {
94
103
if ( code ) {
95
104
WebdriverDebugLog ( `driver has exited with code ${ code } ` )
96
105
if ( ! initialized ) {
0 commit comments