@@ -45,6 +45,19 @@ describe('programmatic use', function () {
4545 } ) ;
4646 } ;
4747
48+ const testStartSelenium3 = function ( done , options , callback ) {
49+ const selenium = require ( '../' ) ;
50+ selenium
51+ . start ( options )
52+ . catch ( done )
53+ . then ( ( cp ) => {
54+ cp . kill ( ) ;
55+ if ( callback ( cp ) !== false ) {
56+ done ( ) ;
57+ }
58+ } ) ;
59+ } ;
60+
4861 it ( 'should install' , ( done ) => {
4962 testInstall ( done , { } , ( log ) => {
5063 if ( ! containsChrome ( log ) ) {
@@ -63,53 +76,103 @@ describe('programmatic use', function () {
6376 } ) ;
6477 } ) ;
6578
66- it ( 'should start' , ( done ) => {
67- testStart ( done , { } , ( log ) => {
68- if ( ! containsChrome ( log ) ) {
69- done ( new Error ( 'Chrome driver should be loaded' ) ) ;
70- return false ;
71- }
72- } ) ;
79+ it ( `should start` , ( done ) => {
80+ if ( process . env . SELENIUM_VERSION . includes ( '3.141.59' ) ) {
81+ testStartSelenium3 ( done , { } , ( cp ) => {
82+ if ( cp . spawnargs && ! cp . spawnargs . some ( containsChrome ) ) {
83+ done ( new Error ( 'Chrome driver should be loaded' ) ) ;
84+ return false ;
85+ }
86+ } ) ;
87+ } else {
88+ testStart ( done , { } , ( log ) => {
89+ if ( ! containsChrome ( log ) ) {
90+ done ( new Error ( 'Chrome driver should be loaded' ) ) ;
91+ return false ;
92+ }
93+ } ) ;
94+ }
7395 } ) ;
7496
7597 it ( 'should start with custom seleniumArgs' , ( done ) => {
76- testStart ( done , { seleniumArgs : [ '--port' , '12345' ] } , ( log ) => {
77- if ( ! containsChrome ( log ) ) {
78- done ( new Error ( 'Chrome driver should be loaded' ) ) ;
79- return false ;
80- }
81- } ) ;
98+ if ( process . env . SELENIUM_VERSION . includes ( '3.141.59' ) ) {
99+ testStartSelenium3 ( done , { seleniumArgs : [ '-port' , '12345' ] } , ( cp ) => {
100+ if ( cp . spawnargs && ! cp . spawnargs . some ( containsChrome ) ) {
101+ done ( new Error ( 'Chrome driver should be loaded' ) ) ;
102+ return false ;
103+ }
104+ } ) ;
105+ } else {
106+ testStart ( done , { seleniumArgs : [ '--port' , '12345' ] } , ( log ) => {
107+ if ( ! containsChrome ( log ) ) {
108+ done ( new Error ( 'Chrome driver should be loaded' ) ) ;
109+ return false ;
110+ }
111+ } ) ;
112+ }
82113 } ) ;
83114
84115 it ( 'should start with the given drivers' , ( done ) => {
85- testStart ( done , { drivers : { firefox : { } } } , ( log ) => {
86- if ( containsChrome ( log ) ) {
87- done ( new Error ( 'Chrome driver should not be loaded' ) ) ;
88- return false ;
89- }
90- } ) ;
116+ if ( process . env . SELENIUM_VERSION . includes ( '3.141.59' ) ) {
117+ testStartSelenium3 ( done , { drivers : { firefox : { } } } , ( cp ) => {
118+ if ( cp . spawnargs && cp . spawnargs . some ( containsChrome ) ) {
119+ done ( new Error ( 'Chrome driver should be loaded' ) ) ;
120+ return false ;
121+ }
122+ } ) ;
123+ } else {
124+ testStart ( done , { drivers : { firefox : { } } } , ( log ) => {
125+ if ( containsChrome ( log ) ) {
126+ done ( new Error ( 'Chrome driver should not be loaded' ) ) ;
127+ return false ;
128+ }
129+ } ) ;
130+ }
91131 } ) ;
92132
93133 it ( 'should start and merge drivers' , ( done ) => {
94- const options = { seleniumArgs : [ '--port' , '4445' ] , drivers : { chrome : { } } } ;
95- testStart ( done , options , ( log ) => {
96- if ( ! containsChrome ( log ) ) {
97- done ( new Error ( 'Chrome driver should be loaded' ) ) ;
98- return false ;
99- }
100- } ) ;
134+ if ( process . env . SELENIUM_VERSION . includes ( '3.141.59' ) ) {
135+ const options = { seleniumArgs : [ '-port' , '4445' ] , drivers : { chrome : { } } } ;
136+ testStartSelenium3 ( done , options , ( cp ) => {
137+ if ( cp . spawnargs && ! cp . spawnargs . some ( containsChrome ) ) {
138+ done ( new Error ( 'Chrome driver should be loaded' ) ) ;
139+ return false ;
140+ }
141+ } ) ;
142+ } else {
143+ const options = { seleniumArgs : [ '--port' , '4445' ] , drivers : { chrome : { } } } ;
144+ testStart ( done , options , ( log ) => {
145+ if ( ! containsChrome ( log ) ) {
146+ done ( new Error ( 'Chrome driver should be loaded' ) ) ;
147+ return false ;
148+ }
149+ } ) ;
150+ }
101151 } ) ;
102152
103153 it ( 'should start with singleDriverStart options' , ( done ) => {
104- testStart (
105- done ,
106- { singleDriverStart : 'firefox' , drivers : { chrome : { } , firefox : { } } , seleniumArgs : [ '--port' , '4446' ] } ,
107- ( log ) => {
108- if ( containsChrome ( log ) ) {
109- done ( new Error ( 'Chrome driver should not be loaded' ) ) ;
110- return false ;
154+ if ( process . env . SELENIUM_VERSION . includes ( '3.141.59' ) ) {
155+ testStartSelenium3 (
156+ done ,
157+ { singleDriverStart : 'firefox' , drivers : { chrome : { } , firefox : { } } , seleniumArgs : [ '-port' , '4446' ] } ,
158+ ( cp ) => {
159+ if ( cp . spawnargs && cp . spawnargs . some ( containsChrome ) ) {
160+ done ( new Error ( 'Chrome driver should be loaded' ) ) ;
161+ return false ;
162+ }
111163 }
112- }
113- ) ;
164+ ) ;
165+ } else {
166+ testStart (
167+ done ,
168+ { singleDriverStart : 'firefox' , drivers : { chrome : { } , firefox : { } } , seleniumArgs : [ '--port' , '4446' ] } ,
169+ ( log ) => {
170+ if ( containsChrome ( log ) ) {
171+ done ( new Error ( 'Chrome driver should not be loaded' ) ) ;
172+ return false ;
173+ }
174+ }
175+ ) ;
176+ }
114177 } ) ;
115178} ) ;
0 commit comments