Selenium WebDriver – How To Download And Set Up the Browser Drivers


One of the challenges we often face with test automation is – setting up the dependency to run the automated test scripts in all the remote virtual machines. For example, downloading & setting up the required version of browser drivers like chromedriver and adding them to the PATH. Doing this setup manually in every machine could be bit annoying.

I would suggest you to go with dockerized selenium grid approach. But in case, you do not want to use docker, You could include the drivers in your framework itself. That is, you add the required executables and push it to the central repo. [I know, some of you might hate this idea! It might increase your project size etc]. But It ensures that – all the dependency required are part of the project. So you would not miss anything in the remote machine to run the test scripts.

But there is some other better approach as well!


Spacelift is a library from Arquillian Team!

Spacelift provides a set of tools (and tasks) that can be used to encapsulate execution of any command into block that can be executed asynchronously and repeated if needed. You reuse a set of existing tasks and implement your own tasks.

Spacelift comes with some very basic tools like DownloadTool, UnzipTool which can be used for setting up the browser drivers.


  • Spacelift executes the tasks in asynchronously.
  • Spacelift can block the execution by using ‘await()’ or ‘awaitAtMost(long , TimeUnit)’
  • Spacelift can execute the given task periodically until some condition / timeout is met.

Add below maven dependency to use Spacelift.


Setting up Browser Driver:

Lets consider this class to download chrome driver and unzip.

public class BrowserDrivers {

    private final static String CHROMEDRIVER_URL = "";

    public static void setupChrome() {

            .to(System.getProperty("user.dir") + "/")
            .toDir(System.getProperty("user.dir") + "/chrome/")

        System.setProperty("", System.getProperty("user.dir") + "/chrome/chromedriver");


This setup will ensure that your chrome browser driver is setup in the remote machine. Your test can be as shown here.

public class ChromeTest {

    public void setupDrivers() {

    public void test1() {
        //your tests

    public void test2() {
        //your tests


If you like to setup the drivers this way, Then I would suggest you to use the Factory pattern as mentioned in this article.

We could modify the abstract DriverManager class to include an abstract method ‘setupDriver’ method. Each extending Driver manager class like ChromeDriverManager will imlement the download and unzip using spacelift as shown above.

public abstract class DriverManager {

    protected WebDriver driver;

    protected abstract void setupDriver();
    protected abstract void startService();
    protected abstract void stopService();
    protected abstract void createDriver();

    public void quitDriver() {
        if (null != driver) {
            driver = null;

    public WebDriver getDriver() {
        if (null == driver) {
        return driver;

Happy Testing & Subscribe 🙂



Share This:

Categories: Arquillian, Articles, Selenium, Utility

1 comment

Leave a Reply

Your email address will not be published. Required fields are marked *