Cannot see WebdriverIO logs in the console (webdriver logs)

6.7k Views Asked by At

I am using WebdriverIO version 5 and would like to see the logs of my test run.

I tried the command: npm run rltest --logLevel=info, but all I can see is the output of the spec reporter.

[chrome 83.0.4103.116 Mac OS X #0-0] Running: chrome (v83.0.4103.116) on Mac OS X
[chrome 83.0.4103.116 Mac OS X #0-0] Session ID: 16d526a6b3cc51f54110024b112b247c
[chrome 83.0.4103.116 Mac OS X #0-0]
[chrome 83.0.4103.116 Mac OS X #0-0] cancel button
[chrome 83.0.4103.116 Mac OS X #0-0]    ✓ Verify that when the user clicks on the Cancel 
button, no changes made to the list
[chrome 83.0.4103.116 Mac OS X #0-0]
[chrome 83.0.4103.116 Mac OS X #0-0] 1 passing (36.2s)

Is there a way to see more detailed logs? Do I need to configure anything inside wdio.conf.js?

Thanks

2

There are 2 best solutions below

1
Vojtech Cerveny On

Check documentation - logLevel

So basically you need to setup this property in wdio.conf.js:

 // ===================
  // Test Configurations
  // ===================
  // Define all options that are relevant for the WebdriverIO instance here
  //
  // Level of logging verbosity: trace | debug | info | warn | error | silent
  logLevel: 'debug',
3
iamdanchiv On

You should see the wdio logs in your console, as WebdriverIO defaults to dumping all the Selenium logs into stdout. Hope I understood correctly and you're talking about the webdriver logs, as below:

[0-0] 2020-07-01T09:28:53.869Z INFO webdriver: [GET] http://127.0.0.1:4444/wd/hub/session/933eeee4135ea0ca37d57f0b807cb29e/element/0.45562246642229964-9/displayed
[0-0] 2020-07-01T09:28:53.878Z INFO webdriver: RESULT true
[0-0] 2020-07-01T09:28:53.879Z INFO webdriver: COMMAND findElement("css selector", "#_evidon-l3 button")
[0-0] 2020-07-01T09:28:53.879Z INFO webdriver: [POST] http://127.0.0.1:4444/wd/hub/session/933eeee4135ea0ca37d57f0b807cb29e/element
[0-0] 2020-07-01T09:28:53.879Z INFO webdriver: DATA { using: 'css selector', value: '#_evidon-l3 button' }
[0-0] 2020-07-01T09:28:53.888Z INFO webdriver: RESULT { ELEMENT: '0.45562246642229964-10' }
[0-0] 2020-07-01T09:28:53.889Z INFO webdriver: COMMAND isElementDisplayed("0.45562246642229964-10")

If this is not the case, please check if you have outputDir option set inside the wdio.conf.js file. If indeed you have this setup, then you are overriding the default, sending the log streams to files inside that path:

e.g: outputDir: 'wdio-logs', (wdio.conf.js file)

enter image description here

The logs should be inside the wdio-x-y.log files. So, either debug your cases using the overridden path log files, or remove outputDir entry from your wdio.conf.js file if you want them inside the console.


Even better, you could be fancy and set outputDir: process.env.CONSOLELOGS ? null : 'wdio/logs/path/here'. Then you can run your checks with a system variable to trigger console logging:

CONSOLELOGS=true npm run rltest <params>