Example usage for org.openqa.selenium.remote CapabilityType ACCEPT_SSL_CERTS

List of usage examples for org.openqa.selenium.remote CapabilityType ACCEPT_SSL_CERTS

Introduction

In this page you can find the example usage for org.openqa.selenium.remote CapabilityType ACCEPT_SSL_CERTS.

Prototype

String ACCEPT_SSL_CERTS

To view the source code for org.openqa.selenium.remote CapabilityType ACCEPT_SSL_CERTS.

Click Source Link

Usage

From source file:FirefoxConsoleExport.java

License:Open Source License

public FirefoxConsoleExport(int port) throws IOException {
    super(port);/*from   w w w . ja v  a2 s .c  o m*/
    start(NanoHTTPD.SOCKET_READ_TIMEOUT, false);
    ClassLoader classLoader = FirefoxConsoleExport.class.getClassLoader();
    DesiredCapabilities cap = new DesiredCapabilities();
    cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    FirefoxProfile fp = new FirefoxProfile();
    File extensionToInstall = new File(classLoader.getResource("firebug-2.0.16-fx.xpi").getFile());
    File extension2 = new File(classLoader.getResource("consoleExport-0.5b5.xpi").getFile());

    fp.addExtension(extensionToInstall);
    fp.addExtension(extension2);

    fp.setPreference("extensions.firebug.currentVersion", "2.0");
    fp.setPreference("extensions.firebug.console.enableSites", "true");
    fp.setPreference("extensions.firebug.net.enableSites", "true");
    fp.setPreference("extensions.firebug.script.enableSites", "true");
    fp.setPreference("extensions.firebug.allPagesActivation", "on");
    fp.setPreference("extensions.firebug.consoleexport.active", "true");
    fp.setPreference("extensions.firebug.consoleexport.serverURL", "http://127.0.0.1:9999");

    cap.setCapability(FirefoxDriver.PROFILE, fp);
    driver = new FirefoxDriver(cap);

}

From source file:ca.nrc.cadc.web.selenium.AbstractWebApplicationIntegrationTest.java

License:Open Source License

/**
 * Override to set up your specific external resource.
 *///from   w w  w  . ja va2 s .co  m
@BeforeClass
public static void setUp() {
    try {
        final String seleniumURL = seleniumServerURL
                + (seleniumServerURL.contains(SELENIUM_SERVER_URL_ENDPOINT) ? ""
                        : SELENIUM_SERVER_URL_ENDPOINT);
        System.out.println("Connecting to " + seleniumURL);

        final String browserDriverName = System.getProperty("driver");
        driverCapabilities = CAPABILITIES_LOOKUP.get(browserDriverName.toLowerCase());
        driverCapabilities.setCapability(CapabilityType.HAS_NATIVE_EVENTS, true);
        driverCapabilities.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT, true);
        driverCapabilities.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
        driverCapabilities.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
        driverCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

        driver = new RemoteWebDriver(new URL(seleniumURL), driverCapabilities);

        username = System.getProperty("user.name");
        password = System.getProperty("user.password");
        webURL = System.getProperty("web.app.url");
    } catch (MalformedURLException e) {
        System.err.println("Can't create URL.");
        e.printStackTrace(System.err);
        throw new RuntimeException(e);
    }

    driver.manage().window().maximize();

    final WebDriver.Timeouts timeouts = driver.manage().timeouts();

    // Safari does not support setTimeout.
    if (!driverCapabilities.getBrowserName().contains("afari")) {
        // Set the timeout to four minutes.
        timeouts.pageLoadTimeout(TIMEOUT_IN_MILLISECONDS, TimeUnit.MILLISECONDS);
    }

    timeouts.setScriptTimeout(TIMEOUT_IN_MILLISECONDS, TimeUnit.MILLISECONDS);
}

From source file:com.ceiwc.compugain.setup.TestBase.java

public DesiredCapabilities chromeProfileSetUp() {
    System.setProperty("webdriver.chrome.driver", getFilePath(CHROMEPATH));
    String downloadFilepath = getFilePath(DOWNLOADSPATH);
    HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
    chromePrefs.put("profile.default_content_settings.popups", 0);
    chromePrefs.put("download.default_directory", downloadFilepath);
    ChromeOptions options = new ChromeOptions();
    HashMap<String, Object> chromeOptionsMap = new HashMap<String, Object>();
    options.setExperimentalOption("prefs", chromePrefs);
    options.addArguments("--test-type");
    DesiredCapabilities cap = DesiredCapabilities.chrome();
    cap.setCapability(ChromeOptions.CAPABILITY, chromeOptionsMap);
    cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    cap.setCapability(ChromeOptions.CAPABILITY, options);
    options.addArguments("--always-authorize-plugins");
    options.addArguments("--ignore-certificate-errors");
    //   logger.info("The Chrome Profile is setup");
    return cap;//  ww  w. ja  va2 s  .  c o m
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

/**
 * This method build a webDriver based on the passed in browser request
 *
 * @param browser/*from www  .j a  v a  2s .  c o m*/
 * @return WebDriver
 * @throws MalformedURLException
 */
private static WebDriver buildWebDriver(String browserName) {
    DesiredCapabilities capability = null;
    BrowserType browserType = BrowserType.getBrowserTypeFromString(browserName);
    switch (browserType) {
    case MARIONETTE:
        FirefoxProfile ffProfile = null;
        ffProfile = new FirefoxProfile();
        ffProfile.setAcceptUntrustedCertificates(true);
        ffProfile.setAssumeUntrustedCertificateIssuer(false);
        DesiredCapabilities cap = DesiredCapabilities.firefox();
        cap.setCapability("marionette", true);
        cap.setCapability("firefox_profile", ffProfile);
        cap.setCapability("handlesAlerts", true);
        sysEnv = System.getenv("webdriver.firefox.marionette");
        if (sysEnv == null) {
            sysEnv = findFileName("C:/apps/selenium", "geckodriver.exe", FileSearchType.File);
            if (sysEnv == null) {
                log.info(
                        "Please set the webdriver.firefox.marionette in system environment variables and restart the PC OR copy all your webdrivers under 'C:/selenium' location");
                throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName);
            } else {
                System.setProperty("webdriver.firefox.marionette", sysEnv);
            }
        }
        return new MarionetteDriver(capability);
    case FIREFOX_DRIVER:
        capability = DesiredCapabilities.firefox();
        FirefoxProfile firefoxProfile = new FirefoxProfile();
        firefoxProfile.setAcceptUntrustedCertificates(true);
        firefoxProfile.setEnableNativeEvents(true);
        firefoxProfile.setAssumeUntrustedCertificateIssuer(true);
        capability.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
        return new FirefoxDriver(capability);
    case CHROME_DRIVER:
        sysEnv = System.getenv("webdriver.chrome.driver");
        if (sysEnv == null) {
            sysEnv = findFileName("C:/apps/selenium", "chromedriver.exe", FileSearchType.File);
            if (sysEnv == null) {
                log.info(
                        "Please set the webdriver.chrome.driver in system environment variables and restart the PC OR copy all your webdrivers under 'C:/selenium' location");
                throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName);
            } else {
                System.setProperty("webdriver.chrome.driver", sysEnv);
            }
        }
        capability = DesiredCapabilities.chrome();
        ChromeOptions options = new ChromeOptions();
        options.addArguments(new String[] { "--allow-running-insecure-content" });
        options.addArguments(new String[] { "--ignore-certificate-errors" });
        options.addArguments(new String[] { "--enable-npapi" });
        options.addArguments(new String[] { "--disable-extensions" });
        options.addArguments(new String[] { "--start-maximized" });
        capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        capability.setCapability(ChromeOptions.CAPABILITY, options);
        return new ChromeDriver(capability);
    case INTERNET_EXPLORER:
        sysEnv = System.getenv("webdriver.ie.driver");
        if (sysEnv == null) {
            sysEnv = findFileName("C:/apps/selenium", "IEDriverServer.exe", FileSearchType.File);
            if (sysEnv == null) {
                log.info(
                        "Please set the webdriver.ie.driver in system environment variables and restart the PC");
                throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName);
            } else {
                System.setProperty("webdriver.ie.driver", sysEnv);
            }
        }
        capability = DesiredCapabilities.internetExplorer();
        capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
        capability.setCapability("ignoreProtectedModeSettings", true);
        capability.setCapability("acceptSslCerts", true);
        capability.setCapability("ignoreZoomSetting", true);
        capability.setCapability("nativeEvents", true);
        capability.setCapability("ie.ensureCleanSession", true);
        return new InternetExplorerDriver(capability);
    case SAFARI:
        capability = DesiredCapabilities.safari();
        capability.setCapability("acceptSslCerts", true);
        capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        capability.setCapability("ensureCleanSession", true);
        capability.setJavascriptEnabled(true);
        return new SafariDriver(capability);
    /*        case OPERA_DRIVER:
    capability = DesiredCapabilities.opera();
    capability.setCapability("opera.host", "127.0.0.1");
    return new OperaDriver();
     */
    case EDGE:
        capability = DesiredCapabilities.edge();
        EdgeOptions option = new EdgeOptions();
        capability.setCapability("edgeOptions", option);
        return new EdgeDriver(capability);
    default:
        log.info(
                "Currenty support is there for Chrome, Firefox, Firefox Marionette, Internet Explorer, Edge, Safari & Opera. Support is not there for "
                        + browserName);
        capability = DesiredCapabilities.firefox();
        FirefoxProfile firefoxProf = new FirefoxProfile();
        firefoxProf.setAcceptUntrustedCertificates(true);
        firefoxProf.setEnableNativeEvents(true);
        firefoxProf.setAssumeUntrustedCertificateIssuer(true);
        capability.setCapability(FirefoxDriver.PROFILE, firefoxProf);
        return new FirefoxDriver(capability);
    }
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

/**
 * This method build a RemoteWebDriver based on the passed in browser request
 *
 * @param browser//from   w  w w  .j  av  a 2s .  c  o  m
 * @return RemoteWebDriver
 *
 */
private static RemoteWebDriver buildRemoteWebDriver(String browserName) {
    DesiredCapabilities capability = null;
    BrowserType browserType = BrowserType.getBrowserTypeFromString(browserName);
    switch (browserType) {
    case MARIONETTE:
        FirefoxProfile ffProfile = null;
        ffProfile = new FirefoxProfile();
        ffProfile.setAcceptUntrustedCertificates(true);
        ffProfile.setAssumeUntrustedCertificateIssuer(false);
        DesiredCapabilities cap = DesiredCapabilities.firefox();
        cap.setCapability("marionette", true);
        cap.setCapability("firefox_profile", ffProfile);
        cap.setCapability("handlesAlerts", true);
        sysEnv = System.getenv("webdriver.firefox.marionette");
        if (sysEnv == null) {
            sysEnv = findFileName("C:/apps/selenium", "geckodriver.exe", FileSearchType.File);
            if (sysEnv == null) {
                log.info(
                        "Please set the webdriver.firefox.marionette in system environment variables and restart the PC OR copy all your webdrivers under 'C:/selenium' location");
                throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName);
            } else {
                System.setProperty("webdriver.firefox.marionette", sysEnv);
            }
        }
        return new MarionetteDriver(capability);
    case FIREFOX_DRIVER:
        capability = DesiredCapabilities.firefox();
        FirefoxProfile firefoxProfile = new FirefoxProfile();
        firefoxProfile.setAcceptUntrustedCertificates(true);
        firefoxProfile.setEnableNativeEvents(true);
        capability.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
        capability.setPlatform(capability.getPlatform());
        capability.setVersion(capability.getVersion());
        return new FirefoxDriver(capability);
    case CHROME_DRIVER:
        sysEnv = System.getenv("webdriver.chrome.driver");
        if (sysEnv == null) {
            sysEnv = findFileName("C:/apps/selenium", "chromedriver.exe", FileSearchType.File);
            if (sysEnv == null) {
                log.info(
                        "Please set the webdriver.chrome.driver in system environment variables and restart the PC OR copy all your webdrivers under 'C:/selenium' location");
                throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName);
            } else {
                System.setProperty("webdriver.chrome.driver", sysEnv);
            }
        }
        capability = DesiredCapabilities.chrome();
        ChromeOptions options = new ChromeOptions();
        options.addArguments(new String[] { "--allow-running-insecure-content" });
        options.addArguments(new String[] { "--ignore-certificate-errors" });
        options.addArguments(new String[] { "--enable-npapi" });
        options.addArguments(new String[] { "--disable-extensions" });
        options.addArguments(new String[] { "--start-maximized" });
        capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        capability.setCapability(ChromeOptions.CAPABILITY, options);
        capability.setPlatform(capability.getPlatform());
        capability.setVersion(capability.getVersion());
        return new ChromeDriver(capability);
    case INTERNET_EXPLORER:
        sysEnv = System.getenv("webdriver.ie.driver");
        if (sysEnv == null) {
            sysEnv = findFileName("C:/apps/selenium", "IEDriverServer.exe", FileSearchType.File);
            if (sysEnv == null) {
                log.info(
                        "Please set the webdriver.ie.driver in system environment variables and restart the PC");
                throw new RuntimeException("Failed to instantiate a WebDriver instance for " + browserName);
            } else {
                System.setProperty("webdriver.ie.driver", sysEnv);
            }
        }
        capability = DesiredCapabilities.internetExplorer();
        capability.setCapability("ignoreProtectedModeSettings", true);
        String browserVersion = capability.getVersion();
        if (browserVersion != null && browserVersion.equals("10")) {
            capability.setPlatform(Platform.WINDOWS);
            capability.setVersion(browserVersion);
        } else if (browserVersion != null && browserVersion.equals("11")) {
            capability.setPlatform(Platform.WIN8_1);
            capability.setVersion(browserVersion);
        }
        capability.setBrowserName("internet explorer");
        capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        return new InternetExplorerDriver(capability);
    case SAFARI:
        capability = DesiredCapabilities.safari();
        capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        capability.setCapability("ensureCleanSession", true);
        capability.setPlatform(capability.getPlatform());
        capability.setVersion(null);
        return new SafariDriver(capability);
    /*         case OPERA_DRIVER:
    capability = DesiredCapabilities.opera();
    capability.setCapability("opera.profile", "/test");
    return new OperaDriver();
    */
    case EDGE:
        capability = DesiredCapabilities.edge();
        EdgeOptions option = new EdgeOptions();
        capability.setCapability("edgeOptions", option);
        return new EdgeDriver(capability);
    default:
        log.info(
                "Currenty support is there for Chrome, Firefox, Firefox Marionette, Internet Explorer, Edge, Safari & Opera. Support is not there for "
                        + browserName);
        capability = DesiredCapabilities.firefox();
        firefoxProfile = new FirefoxProfile();
        firefoxProfile.setAcceptUntrustedCertificates(true);
        firefoxProfile.setEnableNativeEvents(true);
        capability.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
        capability.setPlatform(capability.getPlatform());
        capability.setVersion(capability.getVersion());
        return new FirefoxDriver(capability);
    }
}

From source file:com.cisco.dbds.utils.selenium.SeleniumUtilities.java

License:Open Source License

/**
 * Opens the Firefox instance for Selenium.
 *///w w  w.j a  va 2 s.c o m
public static void openBrowser() {
    try {
        String browser = Validate.readsystemvariable("browser");
        LogHandler.info("Browser:" + browser);

        String digest = Validate.readsystemvariable("browser.digest");
        LogHandler.info("Digest Auth:" + digest);

        if (browser.equals("firefox") && digest.toUpperCase().equals("YES")) {
            LogHandler.info("Fire Fox Driver with addon configuration");
            FirefoxProfile profile = new FirefoxProfile();
            profile.setPreference("browser.link.open_newwindow", 2);
            File extentions = new File(
                    System.getProperty("user.dir") + Validate.readsystemvariable("firefox.addons.path"));
            if (extentions.exists()) {
                for (File extention : extentions.listFiles()) {
                    if (extention.getName().endsWith(".xpi")) {
                        try {
                            profile.addExtension(new File(extention.getAbsolutePath()));
                        } catch (IOException e) {
                            Assert.assertTrue("Exception occured while adding the extension to the profile..",
                                    false);
                        }
                        LogHandler.info("Added extention: " + extention.getName());
                    }
                }
            }
            driver = new FirefoxDriver(profile);
        } else if (browser.equals("firefox") && digest.toUpperCase().equals("NO")) {
            LogHandler.info("Fire Fox Driver without addon configuration");
            driver = new FirefoxDriver();
        } else if (browser.equals("chrome"))

        {
            LogHandler.info("Chrome Driver configuration");
            JarFile jarFile = jarfilehandler.jarForClass(SeleniumUtilities.class);
            jarfilehandler.copyResourcesToDirectory(jarFile, "chrome", "src/it/resources/chrome");
            System.setProperty("webdriver.chrome.driver", "src/it/resources/chrome/chromedriver.exe");
            driver = new ChromeDriver();

        } else if (browser.equals("IE")) {

            LogHandler.info("IE Driver configuration");
            DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
            String IEpath = (SeleniumUtilities.class).getResource("").getPath();
            System.out.println(IEpath.substring(0, IEpath.length() - 31));

            capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
                    true);
            capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

            JarFile jarFile = jarfilehandler.jarForClass(SeleniumUtilities.class);
            // JarFile jarFile = new
            // JarFile("C:\\Users\\amsathishkumar\\.m2\\repository\\com\\cisco\\dbds\\Utils\\0.0.1-Release\\Utils-0.0.1-Release.jar");
            jarfilehandler.copyResourcesToDirectory(jarFile, "internetexplorer",
                    "src/it/resources/InternetExplorer");

            System.setProperty("webdriver.ie.driver", "src/it/resources/internetexplorer/IEDriverServer.exe");
            driver = new InternetExplorerDriver(capabilities);

            // driver = new InternetExplorerDriver();
        } else {
            Assert.assertTrue("include the browswer variable...", false);
        }
    } catch (Exception e) {
        LogHandler.info("Check the varaiables: browser,firefox.addons.path,user.dir");

    }
    //   driver.manage().timeouts().pageLoadTimeout(3, TimeUnit.SECONDS);
    //   driver.manage().timeouts().setScriptTimeout(10, TimeUnit.SECONDS);
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(Integer.parseInt(System.getProperty("implicit.wait")),
            TimeUnit.SECONDS);
    driver.manage().timeouts().pageLoadTimeout(Integer.parseInt(System.getProperty("explicit.wait")),
            TimeUnit.SECONDS);
}

From source file:com.cognifide.aet.worker.drivers.FirefoxWebDriverFactory.java

License:Apache License

@Override
public WebCommunicationWrapper createWebDriver(ProxyServerWrapper proxyServer) throws WorkerException {
    try {/* w  w w  . j  a v a2 s  .  c o m*/
        Proxy proxy = proxyServer.seleniumProxy();
        proxyServer.setCaptureContent(true);
        proxyServer.setCaptureHeaders(true);

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.PROXY, proxy);
        capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

        FirefoxProfile fp = getFirefoxProfile();
        fp.setAcceptUntrustedCertificates(true);
        fp.setAssumeUntrustedCertificateIssuer(false);
        capabilities.setCapability(AetFirefoxDriver.PROFILE, fp);

        return new WebCommunicationWrapperImpl(getFirefoxDriver(fp, capabilities), proxyServer,
                builderFactory.createInstance());
    } catch (Exception e) {
        throw new WorkerException(e.getMessage(), e);
    }
}

From source file:com.consol.citrus.selenium.client.WebClient.java

License:Apache License

private RemoteWebDriver createRemoteWebDriver(BrowserTypeEnum browserType, String serverAddress)
        throws MalformedURLException {
    switch (browserType) {
    case FIREFOX:
        DesiredCapabilities defaultsFF = DesiredCapabilities.firefox();
        defaultsFF.setCapability(FirefoxDriver.PROFILE, createFireFoxProfile());
        return new RemoteWebDriver(new URL(serverAddress), defaultsFF);
    case INTERNET_EXPLORER:
        DesiredCapabilities defaultsIE = DesiredCapabilities.internetExplorer();
        defaultsIE.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        return new RemoteWebDriver(new URL(serverAddress), defaultsIE);
    default://from w  w  w.  ja v  a  2s.c o  m
        DesiredCapabilities defaults = DesiredCapabilities.chrome();
        defaults.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        return new RemoteWebDriver(new URL(serverAddress), defaults);
    }
}

From source file:com.consol.citrus.selenium.endpoint.SeleniumBrowser.java

License:Apache License

/**
 * Creates remote web driver./*from   w  w w .jav a  2s  . co m*/
 * @param browserType
 * @param serverAddress
 * @return
 * @throws MalformedURLException
 */
private RemoteWebDriver createRemoteWebDriver(String browserType, String serverAddress) {
    try {
        switch (browserType) {
        case BrowserType.FIREFOX:
            DesiredCapabilities defaultsFF = DesiredCapabilities.firefox();
            defaultsFF.setCapability(FirefoxDriver.PROFILE, getEndpointConfiguration().getFirefoxProfile());
            return new RemoteWebDriver(new URL(serverAddress), defaultsFF);
        case BrowserType.IE:
            DesiredCapabilities defaultsIE = DesiredCapabilities.internetExplorer();
            defaultsIE.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
            return new RemoteWebDriver(new URL(serverAddress), defaultsIE);
        case BrowserType.CHROME:
            DesiredCapabilities defaultsChrome = DesiredCapabilities.chrome();
            defaultsChrome.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
            return new RemoteWebDriver(new URL(serverAddress), defaultsChrome);
        case BrowserType.GOOGLECHROME:
            DesiredCapabilities defaultsGoogleChrome = DesiredCapabilities.chrome();
            defaultsGoogleChrome.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
            return new RemoteWebDriver(new URL(serverAddress), defaultsGoogleChrome);
        default:
            throw new CitrusRuntimeException("Unsupported remote browser type: " + browserType);
        }
    } catch (MalformedURLException e) {
        throw new CitrusRuntimeException("Failed to access remote server", e);
    }
}

From source file:com.denimgroup.threadfix.selenium.tests.BaseTest.java

License:Mozilla Public License

public BaseTest(String browser) {
    if (browser.equals("chrome")) {
        String location = BaseTest.class.getClassLoader().getResource("Drivers").getFile();
        String log = "";
        if (System.getProperty("os.name").startsWith("Windows")) {
            location = location + "/chromedriver.exe";
            log = "NUL";
        } else {//from w  w w . j  a v a  2s .  co  m
            location = location + "/chromedriver";
            log = "/dev/null";
        }
        service = new ChromeDriverService.Builder().usingDriverExecutable(new File(location)).usingAnyFreePort()
                .withLogFile(new File(log)).build();
        try {
            service.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
        driver = new RemoteWebDriver(service.getUrl(), DesiredCapabilities.chrome());
    }

    if (browser.equals("firefox")) {
        driver = new FirefoxDriver();
    }

    if (browser.equals("IE")) {
        String location = BaseTest.class.getClassLoader().getResource("Drivers").getFile();
        location = location + "/IEDriverServer.exe";
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        driver = new InternetExplorerDriver(capabilities);
    }
}