How to print chromedriver.exe version and exit ?

1,196 views
Skip to first unread message

Alex De Lara

unread,
Apr 8, 2014, 8:58:34 AM4/8/14
to chromedri...@googlegroups.com

I have a "simple" requirement to script automatic updates to chromedriver.

The problem is how easily find the local version: if I simply run "chromedriver.exe" it prints what I want, but it never comes back as the server stays in background.

I was hoping to have something as simple as accept some command to quit, exit, abort, etc like

"echo abort | chromedriver.exe"

So far no luck other than hitting Ctrl-C on its starting window.

I tried also to create a ctrl-c binary file and pipe into but that didnt work either.

Any good idea out there shorter than coding yet another script ?

Alex De Lara

unread,
May 9, 2014, 5:43:57 PM5/9/14
to chromedri...@googlegroups.com
Ok I bit the bullet and wrote this small class just to instantiate chromedriver and exit.
See the comments to compile and run:

Here's the class in case anyone needs this feature.

// -------------------------------------------------------------------------------------------
// This script is to instantiate chromedriver
// Whenever chromedriver starts, it prints to stderr (bummer)
// We have to redirect this script execution to a file in order
//   to be able to retrieve and parse the chromedriver version
//
// Requirements:
//   - chromedriver must be above the directory where it executes
//   - needs to run with selenium-server-standalone in the classpath
//
// Compile with
//    set CLASSPATH=c:\Tools\selenium\selenium-2.39.0\selenium-server-standalone-2.39.0.jar;.
//    javac -d . GetChromedriverVersion.java
//    class is put in ./seltool.updater/GetChromedriverVersion.class
//
// Run with
//    java seltool.updater.GetChromedriverVersion 2>someTempFile
// -----------------------------------------------------------------------------------------------
package seltool.updater;

import java.io.*;

import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import org.openqa.selenium.*;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.firefox.FirefoxDriver;

public class GetChromedriverVersion {

    private static ChromeDriverService service;
    private WebDriver driver;

    public static void main(String[] args)
    {
        GetChromedriverVersion d = new GetChromedriverVersion();
       
        try
        {
            service = new ChromeDriverService.Builder()
                            .usingDriverExecutable( new File( "../chromedriver.exe" ) )
                            .usingAnyFreePort()
                            .build();
           
            service.start();
        } catch (Exception e) {};
       
        service.stop();
    }
}
 




Sam Uong

unread,
May 9, 2014, 6:32:14 PM5/9/14
to Alex De Lara, chromedri...@googlegroups.com
Hi Alex,

Actually chromedriver 2.10 was just released about a week ago. You can download it here:


One of the changes was the addition of a --version (or -v) switch, which prints the version number and immediately exits without starting the server.

$ ./chromedriver --version
ChromeDriver 2.10.267518
$ ./chromedriver -v
ChromeDriver 2.10.267518

Sam.


--
You received this message because you are subscribed to the Google Groups "ChromeDriver Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromedriver-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex De Lara

unread,
May 9, 2014, 8:24:35 PM5/9/14
to chromedri...@googlegroups.com
Awesome, thanks. My script in fact did update my installed files but I didn't realize until you told me. One less thing to maintain. Thanks again.
Reply all
Reply to author
Forward
0 new messages