Example usage for org.openqa.selenium.chrome ChromeDriver ChromeDriver

List of usage examples for org.openqa.selenium.chrome ChromeDriver ChromeDriver

Introduction

In this page you can find the example usage for org.openqa.selenium.chrome ChromeDriver ChromeDriver.

Prototype

public ChromeDriver(ChromeOptions options) 

Source Link

Document

Creates a new ChromeDriver instance with the specified options.

Usage

From source file:com.sugarcrm.candybean.automation.VInterface.java

License:Open Source License

private WebDriver getWebDriver(Type iType) throws Exception {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    //        capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
    WebDriver wd = null;/*w w w .j a  v a  2s  . c  o m*/
    switch (iType) {
    case FIREFOX:
        String profileName = this.config.getValue("browser.firefox_profile", "default");
        File ffBinaryPath = new File(this.config.getPathValue("browser.firefox_binary"));
        FirefoxProfile ffProfile = (new ProfilesIni()).getProfile(profileName);
        //         ffProfile.setEnableNativeEvents(false);
        FirefoxBinary ffBinary = new FirefoxBinary(ffBinaryPath);
        // if (System.getProperty("headless") != null) {
        // FirefoxBinary ffBinary = new FirefoxBinary();//new
        // File("//home//conrad//Applications//firefox-10//firefox"));
        // ffBinary.setEnvironmentProperty("DISPLAY", ":1");
        // webDriver = new FirefoxDriver(ffBinary, ffProfile);
        // }
        candybean.log.info("Instantiating Firefox with profile name: " + profileName + " and binary path: "
                + ffBinaryPath);
        wd = new FirefoxDriver(ffBinary, ffProfile);
        break;
    case CHROME:
        ChromeOptions chromeOptions = new ChromeOptions();
        String chromeDriverLogPath = this.config.getPathValue("browser.chrome_driver_log_path");
        candybean.log.info("chromeDriverLogPath: " + chromeDriverLogPath);
        chromeOptions.addArguments("--log-path=" + chromeDriverLogPath);
        String chromeDriverPath = this.config.getPathValue("browser.chrome_driver_path");
        candybean.log.info("chromeDriverPath: " + chromeDriverPath);
        // chromeOptions.setBinary(new File(chromeDriverPath));
        System.setProperty("webdriver.chrome.driver", chromeDriverPath);
        candybean.log.info("Instantiating Chrome with:\n    log path:" + chromeDriverLogPath
                + "\n    driver path: " + chromeDriverPath);
        wd = new ChromeDriver(chromeOptions);
        break;
    case IE:
        String ieDriverPath = this.config.getPathValue("browser.ie_driver_path");
        candybean.log.info("ieDriverPath: " + ieDriverPath);
        System.setProperty("webdriver.ie.driver", ieDriverPath);
        capabilities = DesiredCapabilities.internetExplorer();
        wd = new InternetExplorerDriver(capabilities);
        break;
    case SAFARI:
        throw new Exception("Selenium: safari browser not yet supported.");
    case ANDROID:
        capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
        capabilities.setCapability(CapabilityType.PLATFORM, "Mac");
        capabilities.setCapability("app", "https://s3.amazonaws.com/voodoo2/ApiDemos-debug.apk");
        wd = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
        break;
    case IOS:
        capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "iOS");
        capabilities.setCapability(CapabilityType.VERSION, "6.0");
        capabilities.setCapability(CapabilityType.PLATFORM, "Mac");
        capabilities.setCapability("app", "https://s3.amazonaws.com/voodoo2/TestApp.zip");
        wd = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
        break;
    default:
        throw new Exception("Selenium: browser type not recognized.");
    }
    long implicitWait = Long.parseLong(config.getValue("perf.implicit_wait_seconds"));
    if (System.getProperty("headless") == null) {
        java.awt.Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        wd.manage().window().setSize(new Dimension(screenSize.width, screenSize.height));
    }
    wd.manage().timeouts().implicitlyWait(implicitWait, TimeUnit.SECONDS);
    return wd;
}

From source file:com.tascape.qa.th.webui.comm.Chrome.java

License:Apache License

public Chrome() {
    String chromeServer = System.getProperty(SYSPROP_CHROME_DRIVER);
    if (chromeServer == null) {
        throw new RuntimeException("Cannot find system property " + SYSPROP_CHROME_DRIVER);
    }//from w  w  w.j a va 2s.  c om

    ChromeOptions options = new ChromeOptions();
    options.addArguments(Arrays.asList("allow-running-insecure-content", "ignore-certificate-errors"));
    //options.addExtensions(new File("/path/to/extension.crx"));
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);

    super.setWebDriver(new ChromeDriver(capabilities));
}

From source file:com.technophobia.webdriver.substeps.runner.DefaultWebDriverFactory.java

License:Open Source License

public WebDriver createWebDriver() {

    final WebDriver webDriver;

    switch (configuration.driverType()) {
    case FIREFOX: {
        final DesiredCapabilities firefoxCapabilities = DesiredCapabilities.firefox();

        setNetworkCapabilities(firefoxCapabilities);

        setLoggingPreferences(firefoxCapabilities);

        webDriver = new FirefoxDriver(firefoxCapabilities);
        break;/*from ww w . j a va  2 s.c  o m*/

    }
    case HTMLUNIT: {
        final HtmlUnitDriver htmlUnitDriver = new HtmlUnitDriver(BrowserVersion.FIREFOX_38);
        htmlUnitDriver.setJavascriptEnabled(!configuration.isJavascriptDisabledWithHTMLUnit());

        // Run via a proxy - firstly try deprecated HTML unit only
        // properties
        final String htmlunitProxyHost = configuration.getHtmlUnitProxyHost();
        if (StringUtils.isNotEmpty(htmlunitProxyHost)) {
            final int htmlunitProxyPort = configuration.getHtmlUnitProxyPort();
            htmlUnitDriver.setProxy(htmlunitProxyHost, htmlunitProxyPort);
        }
        // Run via a proxy - secondly new network proxy settings
        final String proxyHost = configuration.getNetworkProxyHost();
        if (StringUtils.isNotEmpty(proxyHost)) {
            final int proxyPort = configuration.getNetworkProxyPort();
            htmlUnitDriver.setProxy(proxyHost, proxyPort);
        }

        setDriverLocale(htmlUnitDriver);

        webDriver = htmlUnitDriver;
        break;

    }
    case CHROME: {

        String preset = System.getProperty("webdriver.chrome.driver");

        if (preset == null) {
            String driverPath = configuration.getChromeDriverPath();
            Assert.assertNotNull(
                    "Chromedriver path not set as a -Dwebdriver.chrome.driver parameter or in config",
                    driverPath);
            System.setProperty("webdriver.chrome.driver", driverPath);
        }

        final DesiredCapabilities chromeCapabilities = DesiredCapabilities.chrome();
        setNetworkCapabilities(chromeCapabilities);

        setLoggingPreferences(chromeCapabilities);

        webDriver = new ChromeDriver(chromeCapabilities);
        break;

    }
    case IE: {

        // apparently this is required to get around some IE security
        // restriction.
        final DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
        ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
                true);

        LOG.warn("Using IE Webdriver with IGNORING SECURITY DOMAIN");

        setNetworkCapabilities(ieCapabilities);
        webDriver = new InternetExplorerDriver(ieCapabilities);
        break;
    }
    default: {
        throw new IllegalArgumentException("unknown driver type " + configuration.driverType());
    }
    }

    webDriver.manage().window().maximize();

    return webDriver;

}

From source file:com.testmax.handler.SeleniumBaseHandler.java

License:CDDL license

@Before
public synchronized void setUp() throws Exception {
    //set default driver

    if (this.isMultiThreaded) {
        this.libs = null;
        this.createLogFile();
        this.varmap = BaseHandler.threadData.get(threadIndex);
        if (this.libs == null || this.libs.isEmpty()) {
            this.libs = this.parseTagLib();
        }/*from w w w. j  a  va 2 s.  c om*/

    } else {
        this.libs = this.parseTagLib();
        this.varmap = BaseHandler.getVarMap();
        this.threadIndex = this.varmap.get("datasetIndex");
    }

    this.printMessage("####### SELENIUM TEST STARTED #################");

    this.printMessage("####### Dataset:" + this.varmap.values());

    this.timer = new PrintTime();
    File file = null;
    //driver = new FirefoxDriver();

    v_driver = getDeclaredVariable("driver");
    if (v_driver == null || v_driver.isEmpty()) {
        v_driver = ConfigLoader.getConfig("SELENIUM_DRIVER");
        if (v_driver == null || v_driver.isEmpty()) {
            v_driver = "firefox";
        }
    }
    String driver_path = getDeclaredVariable("driver_path");
    if (v_driver.equalsIgnoreCase("chrome")) {
        if (TestEngine.suite != null) {
            file = new File(driver_path != null && !driver_path.isEmpty() ? driver_path : chrome_driver_path);
            if (!file.exists()) {
                String chrome_path = TestEngine.suite.getWorkspace() + TestEngine.suite.getJobname()
                        + "/lib/chromedriver.exe";
                file = new File(chrome_path);
                if (!file.exists()) {
                    file = new File(TestEngine.suite.getWorkspace() + "/lib/chromedriver.exe");
                }
            }
        } else {
            file = new File(driver_path != null && !driver_path.isEmpty() ? driver_path : chrome_driver_path);
        }
        this.printMessage("Chrome Driver Path=" + file.getAbsolutePath());
        System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
        DesiredCapabilities capability = DesiredCapabilities.chrome();
        //capability.setCapability("chrome.switches", Arrays.asList("--allow-running-insecure-content=true"));
        if (System.getProperty("os.name").toLowerCase().contains("mac")) {
            file = new File(ConfigLoader.getWmRoot() + "/lib/chromedriver_mac");
            System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
            capability.setCapability("platform", Platform.ANY);
            capability.setCapability("binary", "/Application/chrome"); //for linux "chrome.switches", "--verbose"
            capability.setCapability("chrome.switches", "--verbose");
            driver = new ChromeDriver(capability);

        } else {
            driver = new ChromeDriver(capability);
        }
    } else if (v_driver.equalsIgnoreCase("ie")) {
        if (is64bit()) {
            file = new File(driver_path != null && !driver_path.isEmpty() ? driver_path : ie_driver_path64bit);
        } else {
            file = new File(driver_path != null && !driver_path.isEmpty() ? driver_path : ie_driver_path32bit);
        }
        this.printMessage("##### IE DRIVER PATH=" + file.getAbsolutePath());
        System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
        DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
        capability.setCapability("acceptSslCerts", true);
        capability.setCapability("platform", Platform.WINDOWS);
        capability.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
        if (is64bit()) {
            capability.setCapability("iedriver-version", "x64_2.41.0");
        }
        //capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
        driver = new InternetExplorerDriver(capability);
        maxTimeToWait = maxTimeToWait * 5;
        this.isIE = true;

    } else if (v_driver.equalsIgnoreCase("firefox")) {

        /*file = new File("firebug-1.8.1.xpi");
        FirefoxProfile firefoxProfile = new FirefoxProfile();
        firefoxProfile.setPreference("security.mixed_content.block_active_content", false);
        firefoxProfile.setPreference("security.mixed_content.block_display_content", true);
        firefoxProfile.setPreference("browser.cache.disk.enable", true);
        firefoxProfile.addExtension(file);
        firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.8.1"); // Avoid startup screen
        driver = new FirefoxDriver(firefoxProfile);
        */
        if (System.getProperty("os.name").toLowerCase().contains("mac")) {
            DesiredCapabilities capability = DesiredCapabilities.firefox();
            capability.setCapability("platform", Platform.ANY);
            capability.setCapability("binary", "/Application/firefox"); //for linux
            //capability.setCapability("binary", "/ms/dist/fsf/PROJ/firefox/16.0.0/bin/firefox"); //for linux

            //capability.setCapability("binary", "C:\\Program Files\\Mozilla  Firefox\\msfirefox.exe"); //for windows                
            driver = new FirefoxDriver(capability);

        } else {
            //
            driver = new FirefoxDriver();
        }
    } else if (v_driver.equalsIgnoreCase("safari")) {

        if (System.getProperty("os.name").toLowerCase().contains("mac")) {
            this.printMessage("#####STARTING Safri in Mac ####");
            DesiredCapabilities capability = DesiredCapabilities.safari();
            capability.setCapability("platform", Platform.ANY);
            capability.setCapability("binary", "/Application/safari"); //for linux
            driver = new SafariDriver(capability);

        } else {
            // Read Instruction for Safari Extension
            //http://rationaleemotions.wordpress.com/2012/05/25/working-with-safari-driver/
            // Get certificate from https://docs.google.com/folder/d/0B5KGduKl6s6-ZGpPZlA0Rm03Nms/edit
            this.printMessage("#####STARTING Safri in Windows ####");
            String safari_install_path = "C:\\Program Files (x86)\\Safari\\";
            DesiredCapabilities capability = DesiredCapabilities.safari();
            capability.setCapability("platform", Platform.ANY);
            capability.setCapability("binary", safari_install_path + "Safari.exe"); //for windows 
            //capability.setCapability(SafariDriver.DATA_DIR_CAPABILITY, "C:\\Program Files (x86)\\Safari\\SafariData");
            //System.setProperty("webdriver.safari.driver", safari_install_path+"SafariDriver.safariextension\\");
            driver = new SafariDriver(capability);

        }
    } else if (v_driver.equalsIgnoreCase("htmlunit")) {
        DesiredCapabilities capability = DesiredCapabilities.htmlUnit();
        capability.setJavascriptEnabled(true);
        //capability.setCapability("browserName","chrome");
        //capability.setBrowserName(BrowserVersion.CHROME);
        driver = new HtmlUnitDriver(capability);

    } else {
        file = new File(driver_path != null && !driver_path.isEmpty() ? driver_path : chrome_driver_path);
        System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
        driver = new ChromeDriver();
    }

    baseUrl = ConfigLoader.getConfig("BASE_APPLICATION_URL");
    baseUrl = baseUrl.replace("[env]", ConfigLoader.getConfig("QA_TEST_ENV"));
    for (Cookie cookie : driver.manage().getCookies()) {
        printMessage("name=" + cookie.getName());
        printMessage("domain=" + cookie.getDomain());
        printMessage("path=" + cookie.getPath());
        printMessage("value=" + cookie.getValue());
    }
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();

    if (this.varmap.get("browserwidth") != null) {
        try {
            browserwidth = new Integer(this.varmap.get("browserwidth"));
        } catch (Exception e) {
            browserwidth = 1020;
        }
    }
    driver.manage().window().setSize(new Dimension(browserwidth, (int) screenSize.getHeight()));
    String removecookie = getDeclaredVariable("removecookie");
    if (this.isEmptyValue(removecookie) || removecookie.equalsIgnoreCase("yes")) {
        driver.manage().deleteAllCookies();
    }
    driver.manage().timeouts().implicitlyWait(maxTimeToWait, TimeUnit.SECONDS);
    driverList.put(this.threadIndex, driver);
    this.resetTestResult();

}

From source file:com.testmax.util.JavaScriptUtl.java

License:CDDL license

public WebDriver initWebDriverDriver(String browser) {

    this.browser = browser;

    File file = null;/*from  w  ww.  ja  v  a 2  s. c o  m*/
    if (browser == null || browser.isEmpty()) {
        browser = "firefox";
    }
    try {
        String driver_path = "";
        if (browser.equalsIgnoreCase("chrome")) {
            if (TestEngine.suite != null) {
                String chrome_path = TestEngine.suite.getWorkspace() + TestEngine.suite.getJobname()
                        + "/lib/chromedriver.exe";
                file = new File(chrome_path);
                if (!file.exists()) {
                    file = new File(TestEngine.suite.getWorkspace() + "/lib/chromedriver.exe");
                }
            } else {
                file = new File(
                        driver_path != null && !driver_path.isEmpty() ? driver_path : chrome_driver_path);
            }
            WmLog.printMessage("Chrome Driver Path=" + file.getAbsolutePath());
            System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
            if (System.getProperty("os.name").toLowerCase().contains("mac")) {
                file = new File(ConfigLoader.getWmRoot() + "/lib/chromedriver_mac");
                System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
                DesiredCapabilities capability = DesiredCapabilities.chrome();
                capability.setCapability("platform", Platform.ANY);
                capability.setCapability("binary", "/Application/chrome"); //for linux
                driver = new ChromeDriver(capability);

            } else {
                driver = new ChromeDriver();
            }
        } else if (browser.equalsIgnoreCase("ie")) {
            if (is64bit()) {
                file = new File(
                        driver_path != null && !driver_path.isEmpty() ? driver_path : ie_driver_path64bit);
            } else {
                file = new File(
                        driver_path != null && !driver_path.isEmpty() ? driver_path : ie_driver_path32bit);
            }
            WmLog.printMessage("##### IE DRIVER PATH=" + file.getAbsolutePath());
            System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
            driver = new InternetExplorerDriver();
            maxTimeToWait = maxTimeToWait * 5;

        } else if (browser.equalsIgnoreCase("firefox")) {
            DesiredCapabilities capability = DesiredCapabilities.firefox();
            LoggingPreferences prefs = new LoggingPreferences();
            prefs.enable(LogType.BROWSER, Level.ALL);
            capability.setCapability(CapabilityType.LOGGING_PREFS, prefs);

            if (System.getProperty("os.name").toLowerCase().contains("mac")) {
                //DesiredCapabilities capability = DesiredCapabilities.firefox();
                capability.setCapability("platform", Platform.ANY);
                capability.setCapability("binary", "/Application/firefox"); //for linux

                driver = new FirefoxDriver(capability);

            } else {

                driver = new FirefoxDriver(capability);
            }
        } else if (browser.equalsIgnoreCase("safari")) {

            if (System.getProperty("os.name").toLowerCase().contains("mac")) {
                WmLog.printMessage("#####STARTING Safri in Mac ####");
                DesiredCapabilities capability = DesiredCapabilities.safari();
                capability.setCapability("platform", Platform.ANY);
                capability.setCapability("binary", "/Application/safari"); //for linux
                driver = new SafariDriver(capability);

            } else {
                // Read Instruction for Safari Extension
                //http://rationaleemotions.wordpress.com/2012/05/25/working-with-safari-driver/
                // Get certificate from https://docs.google.com/folder/d/0B5KGduKl6s6-ZGpPZlA0Rm03Nms/edit
                WmLog.printMessage("#####STARTING Safri in Windows ####");
                String safari_install_path = "C:\\Program Files (x86)\\Safari\\";
                DesiredCapabilities capability = DesiredCapabilities.safari();
                capability.setCapability("platform", Platform.ANY);
                capability.setCapability("binary", safari_install_path + "Safari.exe"); //for windows 
                //capability.setCapability(SafariDriver.DATA_DIR_CAPABILITY, "C:\\Program Files (x86)\\Safari\\SafariData");
                //System.setProperty("webdriver.safari.driver", safari_install_path+"SafariDriver.safariextension\\");
                driver = new SafariDriver(capability);

            }
        } else if (browser.equalsIgnoreCase("htmlunit")) {
            DesiredCapabilities capability = DesiredCapabilities.htmlUnit();
            capability.setJavascriptEnabled(true);
            //capability.setCapability("browserName","chrome");
            //capability.setBrowserName(BrowserVersion.CHROME);
            driver = new HtmlUnitDriver(capability);

        } else {
            file = new File(driver_path != null && !driver_path.isEmpty() ? driver_path : chrome_driver_path);
            System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
            driver = new ChromeDriver();

        }
        driver.manage().timeouts().implicitlyWait(maxTimeToWait, TimeUnit.SECONDS);

    } catch (Exception e) {

        WmLog.printMessage("******** FAILED to launch browser=" + this.browser + " :" + e.getMessage());
        e.printStackTrace();
    }

    return driver;
}

From source file:com.thjug.bgile.webdriver.DefaultWebDriverProvider.java

License:Creative Commons License

@Override
protected ChromeDriver createChromeDriver() {
    final DesiredCapabilities dc = DesiredCapabilities.chrome();
    final String[] cmdOptions = { "--ignore-certificate-errors" };
    dc.setCapability("chrome.switches", Arrays.asList(cmdOptions));

    final ChromeOptions options = new ChromeOptions();
    options.addArguments("test-type");
    dc.setCapability(ChromeOptions.CAPABILITY, options);
    return new ChromeDriver(dc);
}

From source file:com.vaadin.testbench.parallel.setup.LocalDriver.java

/**
 * Creates a {@link WebDriver} instance used for running the test locally
 * for debug purposes.//from   w ww.  j av  a2s  . co m
 */
static public WebDriver createDriver(DesiredCapabilities desiredCapabilities) {
    WebDriver driver;
    if (BrowserUtil.isFirefox(desiredCapabilities)) {
        String firefoxPath = System.getProperty("firefox.path");
        String profilePath = System.getProperty("firefox.profile.path");

        if (firefoxPath != null) {
            if (profilePath != null) {
                File profileDir = new File(profilePath);
                FirefoxProfile profile = new FirefoxProfile(profileDir);
                driver = new FirefoxDriver(new FirefoxBinary(new File(firefoxPath)), profile);
            } else {
                driver = new FirefoxDriver(new FirefoxBinary(new File(firefoxPath)), null);
            }

        } else {
            driver = new FirefoxDriver();
        }
    } else if (BrowserUtil.isChrome(desiredCapabilities)) {
        // Tells chrome not to show warning
        // "You are using an unsupported command-line flag: --ignore-certifcate-errors".
        // #14319
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--test-type ");
        driver = new ChromeDriver(options);
    } else if (BrowserUtil.isSafari(desiredCapabilities)) {
        driver = new SafariDriver();
    } else if (BrowserUtil.isPhantomJS(desiredCapabilities)) {
        driver = new PhantomJSDriver();
    } else {
        throw new RuntimeException(
                "Not implemented support for running locally on " + desiredCapabilities.getBrowserName());
    }

    return TestBench.createDriver(driver);
}

From source file:com.worldline.easycukes.selenium.WebDriverFactory.java

License:Open Source License

/**
 * Creates a new chrome driver instance/* w ww .  j  ava2  s. c  o m*/
 *
 * @return a ChromeDriver instance
 */
private static WebDriver newLocalChromeDriver() {
    if (configuration.getValues().selenium != null
            && configuration.getValues().selenium.getChrome_driver_path() != null) {
        final File file_chrome = new File(configuration.getValues().selenium.getChrome_driver_path());
        System.setProperty("webdriver.chrome.driver", file_chrome.getAbsolutePath());
    }
    return new ChromeDriver(chromeCapabilities());
}

From source file:contentspeed.ContentSpeedTest.java

public static void main(String[] args) {

    try {//from   ww w.jav  a 2s .c  o m
        System.setProperty("webdriver.chrome.driver",
                "D:\\Proiecte\\selenium-java-2.47.1\\selenium-2.47.1\\chromedriver_win32\\chromedriver.exe");

        ChromeOptions options = new ChromeOptions();

        options.addArguments("--start-maximized");

        driver = new ChromeDriver(options);

        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

        driver.get(
                "https://www.armonianaturii.ro/ceaiuri-naturale/ceaiuri-medicinale-simple/ceai-conuri-de-hamei-50g-plafar-plaf-00025.html");

        objProdus = new ProdusCeai(driver);

        objProdus.Actions();

        objCos = new CosCumparaturi(driver);

        objCos.Completeaza("Anda", "Cristea", "andadeacu2@yahoo.com", "0741010736", "observatii test      ",
                "Bucuresti", "Bucuresti", "strada Fericirii nr. 9");

        driver.quit();
    } catch (WebDriverException ex) {

        ex.printStackTrace();
        driver.quit();
    }

}

From source file:contentspeed.RunSiteTest.java

public static void main(String[] args) {

    try {/*from   ww w  .j a v a 2 s.  com*/

        System.setProperty("webdriver.chrome.driver",
                "D:\\Documentatie\\Selenium\\ChromeDriver\\chromedriver234.exe");

        ChromeOptions optionsChrome = new ChromeOptions();

        optionsChrome.addArguments("--start-maximized");

        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("browser", "Chrome");
        caps.setCapability("chrome.switches", "--start-maximized");

        caps.setCapability("os", "Windows");
        caps.setCapability("os_version", "10");
        caps.setCapability("resolution", "1366x768");
        caps.setCapability(ChromeOptions.CAPABILITY, optionsChrome);

        driver = new ChromeDriver(caps);

        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

        driver.get(Constants.URLProdus);

        objProdus = new ProdusCeai(driver);

        objProdus.Actions("Anda", "Cristea", "andadeacu2@yahoo.com", "0741010736", "Bucuresti", "Bucuresti",
                "strada Fericirii nr. 9", "observatii test      ");

        //driver.quit();

    } catch (WebDriverException ex) {

        ex.printStackTrace();

        //driver.quit();

    }
}