UNPKG

1.68 kBMarkdownView Raw
1### Logging
2
3#### Selenium Process
4
5By default, Selenium sends [logging messages to stderr](https://code.google.com/p/selenium/issues/detail?id=7957).
6
7The selenium-standalone cli tool (`selenium-standalone start`) will output the logging messages to your `process.stderr`. So you do see them in the console.
8
9If you are using the programmatic API, you can retrieve the `stderr` messages by doing this:
10
11```js
12const selenium = require('selenium-standalone');
13selenium.start(function(err, child) {
14 child.stderr.on('data', function(data){
15 console.log(data.toString());
16 });
17});
18```
19
20You can also forward the `stderr` to your `process.stderr` like the cli does:
21
22```js
23const selenium = require('selenium-standalone');
24selenium.start({
25 spawnOptions: {
26 stdio: 'inherit'
27 }
28}, function(err, child) {
29 // child.stderr now sent to your `process.stderr`
30});
31```
32
33#### Debug Logs for Selenium Standalone Process
34
35At times you may need to get debug logs for what `selenium-standalone` is doing. In your environment variables set `DEBUG=selenium-standalone:*`. This will enable extra log statements to be shown in stderr.
36
37**Example:**
38```text
39$ DEBUG=selenium-standalone:* selenium-standalone install --drivers.chrome.version=87.0.4280.20
40 selenium-standalone:env-details Platform: darwin 19.6.0 +0ms
41 selenium-standalone:env-details Architecture: x64 +1ms
42 selenium-standalone:env-details Node.js: v12.18.4 +0ms
43 selenium-standalone:env-details Package Version: 6.21.0 +0ms
44 selenium-standalone:cli Started via CLI with: [ '/usr/local/bin/node',
45 '/tmp/selenium-standalone/bin/selenium-standalone',
46 'install',
47 '--drivers.chrome.version=87.0.4280.20' ]
48 ...
49```