com.fireblade.WebDriver.WebDriverFactory.java Source code

Java tutorial

Introduction

Here is the source code for com.fireblade.WebDriver.WebDriverFactory.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.fireblade.WebDriver;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

/**
 * A factory to create a webdriver instance
 * 
 * @author swilliams
 */
public class WebDriverFactory {

    private WebDriver driver;

    public WebDriver createDriver(String driverType) {
        switch (driverType) {
        case "HtmlUnitDriver":
            driver = new HtmlUnitDriver();
            break;
        case "FirefoxDriver":
            driver = new FirefoxDriver();
            break;
        }
        return driver;
    }

}