0

I’m using Selenium with ChromeDriverService.

In its base class, DriverService, it starts the service and prints output messages to System.err stream.

private CommandLine process = null;

  public void start() throws IOException {
    lock.lock();
    try {
      if (process != null) {
        return;
      }
      process = new CommandLine(this.executable, args.toArray(new String[] {}));
      process.setEnvironmentVariables(environment);
      process.copyOutputTo(System.err);
      process.executeAsync();

      waitUntilAvailable();
    } finally {
      lock.unlock();
    }
  }

My first question is why to the error stream? It just prints some info messages about the initialization of chrome driver.

In my application, everything that goes to System.err shown in the app’s log with SEVERE log level.

My second question is how can I avoid it and show it as INFO log level? It is impossible to extend ChromeDriverService and override the start method, because DriverService contains some private data members that I need and can’t access to.

Thanks.

P.S. I’m using Selenium 2.5.2 but it’s the same concept in the newer versions

user3364652
  • 480
  • 8
  • 23
  • Have you configured the app with any logging service like log4j etc? – Naman Sep 18 '17 at 14:13
  • I'm not sure. Its a very large app with 150+ developers, I'm not familiar with the logging implementation. Just because of Selenium messages the logic of System.err -> show as SEVERE won't be changed. But why are you asking? – user3364652 Sep 18 '17 at 15:03

1 Answers1

0

Selenium 3.14.0 From DriverService, you are correct the default is System.err. It does look like you can change this default value as shown below and in the newer version the start() method has changed to use getOutputStream(). This will now allow you to change the default value.

private OutputStream outputStream = System.err;  // default


// You should call this method and set the output to your desired location
    public void sendOutputTo(OutputStream outputStream) {
      this.outputStream = Preconditions.checkNotNull(outputStream);
    }


public void start() throws IOException {
    lock.lock();
    try {
      if (process != null) {
        return;
      }
      process = new CommandLine(this.executable, args.toArray(new String[] {}));
      process.setEnvironmentVariables(environment);
      process.copyOutputTo(getOutputStream());   // This has changed...
      process.executeAsync();

      waitUntilAvailable();
    } finally {
      lock.unlock();
    }
  }
mancocapac
  • 812
  • 6
  • 23