@@ -216,7 +216,8 @@ describe('SeleniumServer Transport Tests', function () {
216216 session,
217217 serverPath,
218218 serverPort,
219- options
219+ options,
220+ client
220221 } ;
221222 }
222223
@@ -260,6 +261,126 @@ describe('SeleniumServer Transport Tests', function () {
260261 assert . ok ( logFilePath . endsWith ( 'testModuleKey_selenium-server.log' ) ) ;
261262 } ) ;
262263
264+ it ( 'test per-worker log file path when running in worker without log_file_name set' , async function ( ) {
265+ mockery . registerMock ( '../../runner/concurrency/index.js' , {
266+ isWorker : function ( ) {
267+ return true ;
268+ }
269+ } ) ;
270+
271+ mockery . registerMock ( 'geckodriver' , {
272+ path : ''
273+ } ) ;
274+
275+ mockery . registerMock ( 'chromedriver' , {
276+ path : ''
277+ } ) ;
278+
279+ mockery . registerMock ( '@nightwatch/selenium-server' , {
280+ path : '/path/to/selenium-server-standalone.3.0.jar'
281+ } ) ;
282+
283+ let logFilePath ;
284+ const { client} = await SeleniumServerTestSetup ( {
285+ desiredCapabilities : {
286+ browserName : 'chrome'
287+ } ,
288+ selenium : {
289+ port : 9999 ,
290+ start_process : true
291+ }
292+ } , {
293+ onLogFile ( filePath ) {
294+ logFilePath = filePath ;
295+ }
296+ } ) ;
297+
298+ // The log file name should include the moduleKey, timestamp and end with _selenium-server.log
299+ assert . ok ( / t e s t M o d u l e K e y _ [ 0 - 9 ] + _ s e l e n i u m - s e r v e r \. l o g $ / . test ( logFilePath ) ) ;
300+ // The log_file_name should be unchanged
301+ assert . strictEqual ( client . settings . webdriver . log_file_name , '' ) ;
302+ } ) ;
303+
304+ it ( 'test log file path when not running in worker with log_file_name set' , async function ( ) {
305+ mockery . registerMock ( 'geckodriver' , {
306+ path : ''
307+ } ) ;
308+
309+ mockery . registerMock ( 'chromedriver' , {
310+ path : ''
311+ } ) ;
312+
313+ mockery . registerMock ( '@nightwatch/selenium-server' , {
314+ path : '/path/to/selenium-server-standalone.3.0.jar'
315+ } ) ;
316+
317+ let logFilePath ;
318+ const { client} = await SeleniumServerTestSetup ( {
319+ desiredCapabilities : {
320+ browserName : 'chrome'
321+ } ,
322+ selenium : {
323+ port : 9999 ,
324+ start_process : true
325+ } ,
326+ webdriver : {
327+ log_file_name : 'customModuleKey'
328+ }
329+ } , {
330+ onLogFile ( filePath ) {
331+ logFilePath = filePath ;
332+ }
333+ } ) ;
334+
335+ // The log file should include the customModuleKey without the timestamp.
336+ assert . ok ( logFilePath . endsWith ( 'customModuleKey_selenium-server.log' ) ) ;
337+ // No change in the log_file_name value as we're not running in worker
338+ assert . strictEqual ( client . settings . webdriver . log_file_name , 'customModuleKey' ) ;
339+ } ) ;
340+
341+ it ( 'test per-worker log file path when running in worker with log_file_name set' , async function ( ) {
342+ mockery . registerMock ( '../../runner/concurrency/index.js' , {
343+ isWorker : function ( ) {
344+ return true ;
345+ }
346+ } ) ;
347+
348+ mockery . registerMock ( 'geckodriver' , {
349+ path : ''
350+ } ) ;
351+
352+ mockery . registerMock ( 'chromedriver' , {
353+ path : ''
354+ } ) ;
355+
356+ mockery . registerMock ( '@nightwatch/selenium-server' , {
357+ path : '/path/to/selenium-server-standalone.3.0.jar'
358+ } ) ;
359+
360+ let logFilePath ;
361+ const { client} = await SeleniumServerTestSetup ( {
362+ desiredCapabilities : {
363+ browserName : 'chrome'
364+ } ,
365+ selenium : {
366+ port : 9999 ,
367+ start_process : true
368+ } ,
369+ webdriver : {
370+ log_file_name : 'customModuleKey'
371+ }
372+ } , {
373+ onLogFile ( filePath ) {
374+ logFilePath = filePath ;
375+ }
376+ } ) ;
377+
378+ // The log file name should include the customModuleKey, timestamp and end with _selenium-server.log
379+ assert . ok ( / c u s t o m M o d u l e K e y _ [ 0 - 9 ] + _ s e l e n i u m - s e r v e r \. l o g $ / . test ( logFilePath ) ) ;
380+ // The log_file_name should also be updated to include the timestamp when running in worker
381+ assert . ok ( / ^ c u s t o m M o d u l e K e y _ [ 0 - 9 ] + $ / . test ( client . settings . webdriver . log_file_name ) ) ;
382+ } ) ;
383+
263384 it ( 'test create session with selenium server 3 -- with drivers' , async function ( ) {
264385 mockery . registerMock ( 'geckodriver' , {
265386 path : '/path/to/geckodriver'
0 commit comments