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() 

Source Link

Document

Creates a new ChromeDriver using the ChromeDriverService#createDefaultService default server configuration.

Usage

From source file:testing.CustomerLoginTest.java

public static void main(String[] args) {
    System.setProperty("webdriver.chrome.driver", "web/WEB-INF/chromedriver.exe");
    // TODO code application logic here
    // Initialize driver      
    driver = new ChromeDriver();

    //Go to URL      
    driver.get("http://localhost:8080/IowaAir/logIn.jsp");
    driver.manage().window().maximize();

    driver.findElement(By.xpath("/html/body/div[2]/form/input[1]")).sendKeys("beer@iowaair.net");
    driver.findElement(By.xpath("/html/body/div[2]/form/input[2]")).sendKeys("password");
    driver.findElement(By.xpath("/html/body/div[2]/form/input[3]")).click();

    String url = driver.getCurrentUrl();
    if (url.equals("http://localhost:8080/IowaAir/home.jsp")) {
        System.out.println("Login Successful");
    } else {//  www. j  a  va 2  s  .c  o m
        System.out.println("Login failed");
    }
    driver.quit();
}

From source file:testing.EmployeeLoginTest.java

public static void main(String[] args) {
    System.setProperty("webdriver.chrome.driver", "web/WEB-INF/chromedriver.exe");
    // TODO code application logic here
    // Initialize driver      
    driver = new ChromeDriver();

    //Go to URL      
    driver.get("http://localhost:8080/IowaAir/logIn.jsp");
    driver.manage().window().maximize();

    driver.findElement(By.xpath("/html/body/div[2]/form/input[1]")).sendKeys("johndoe@iowaair.net");
    driver.findElement(By.xpath("/html/body/div[2]/form/input[2]")).sendKeys("password");
    driver.findElement(By.xpath("/html/body/div[2]/form/input[3]")).click();

    String url = driver.getCurrentUrl();
    if (url.equals("http://localhost:8080/IowaAir/employeeLanding.jsp")) {
        System.out.println("Login Successful");
    } else {/*  w w  w. j  a  v a 2s.co  m*/
        System.out.println("Login failed");
    }
    driver.quit();
}

From source file:testing.EmployeeSearchFlightTest.java

public static void main(String[] args) {
    System.setProperty("webdriver.chrome.driver", "web/WEB-INF/chromedriver.exe");
    // TODO code application logic here
    // Initialize driver      
    driver = new ChromeDriver();

    //Go to URL      
    driver.get("http://localhost:8080/IowaAir/logIn.jsp");
    driver.manage().window().maximize();

    driver.findElement(By.xpath("/html/body/div[2]/form/input[1]")).sendKeys("johndoe@iowaair.net");
    driver.findElement(By.xpath("/html/body/div[2]/form/input[2]")).sendKeys("password");
    driver.findElement(By.xpath("/html/body/div[2]/form/input[3]")).click();

    String url = driver.getCurrentUrl();
    if (url.equals("http://localhost:8080/IowaAir/employeeLanding.jsp")) {
        System.out.println("Login Successful");
        driver.findElement(By.xpath("/html/body/div[2]/ul/li[2]/a")).click();
        url = driver.getCurrentUrl();//  ww w.ja  v  a2s  .c o  m
        if (url.equals("http://localhost:8080/IowaAir/employeeFlightSearch.jsp")) {
            System.out.println("Search Flight page successful");
            driver.findElement(By.xpath("//*[@id=\"radioButtons\"]/input[2]")).click();
            Select origin = new Select(driver.findElement(By.xpath("//*[@id=\"form1\"]/select[1]")));
            origin.selectByVisibleText("ORD");
            Select destination = new Select(driver.findElement(By.xpath("//*[@id=\"form1\"]/select[2]")));
            destination.selectByVisibleText("SFO");
            driver.findElement(By.xpath("//*[@id=\"form1\"]/input[1]")).sendKeys("05/05/2017");
            driver.findElement(By.xpath("//*[@id=\"form1\"]/div/button")).click();
            url = driver.getCurrentUrl();
            if (url.equals(
                    "http://localhost:8080/IowaAir/searchResults.jsp?origin=ORD&destination=SFO&d_date=2017-05-05&r_date=&num_of_passengers=1")) {
                System.out.println("Search successful");
                driver.findElement(By.xpath("//*[@id=\"inner\"]/tbody/tr[2]/td[10]/form/input[3]")).click();
                url = driver.getCurrentUrl();
                if (url.equals("http://localhost:8080/IowaAir/confirmBooking.jsp")) {
                    System.out.println("Selection successful");
                    driver.findElement(By.xpath("/html/body/div[2]/b/form[1]/p/input")).click();
                    url = driver.getCurrentUrl();

                    if (url.equals("http://localhost:8080/IowaAir/employeePassengerInfo.jsp")) {
                        System.out.println("Confirmed successful");
                        driver.findElement(By.xpath("/html/body/div[2]/form/input[1]"))
                                .sendKeys("brady-breitbach@uiowa.edu");
                        driver.findElement(By.xpath("/html/body/div[2]/form/input[2]")).sendKeys("Brady");
                        driver.findElement(By.xpath("/html/body/div[2]/form/input[3]")).sendKeys("Breitbach");
                        Select seat = new Select(driver.findElement(By.xpath("/html/body/div[2]/form/select")));
                        seat.selectByIndex(2);
                        driver.findElement(By.xpath("/html/body/div[2]/form/input[4]")).sendKeys("1");
                        driver.findElement(By.xpath("/html/body/div[2]/form/input[6]")).click();
                        url = driver.getCurrentUrl();
                        if (url.equals("http://localhost:8080/IowaAir/purchaseFlight.jsp")) {
                            System.out.println("Passenger Info successful");
                            driver.findElement(By.xpath("/html/body/div[2]/form/input[7]"))
                                    .sendKeys("0123456789");
                            Select year = new Select(
                                    driver.findElement(By.xpath("/html/body/div[2]/form/select[2]")));
                            year.selectByVisibleText("20");
                            driver.findElement(By.xpath("/html/body/div[2]/form/input[8]")).sendKeys("123");
                            driver.findElement(By.xpath("/html/body/div[2]/form/input[9]")).click();
                            url = driver.getCurrentUrl();
                            if (url.equals("http://localhost:8080/IowaAir/employeeLanding.jsp")) {
                                System.out.println("Purchase Successful");
                            } else {
                                System.out.println("Purchase failed");
                            }
                        } else {
                            System.out.println("Passenger Info failed");
                        }

                    } else {
                        System.out.println("Confirmed failed");
                    }
                } else {
                    System.out.println("Selection failed");
                }
            } else {
                System.out.println("Seach failed");
            }
        } else {
            System.out.println("Search Flight page failed");
        }
    } else {
        System.out.println("Login failed");
    }
    driver.quit();
}

From source file:testing.MultiCityFlightSearchTest.java

public static void main(String[] args) {
    System.setProperty("webdriver.chrome.driver", "web/WEB-INF/chromedriver.exe");
    // TODO code application logic here
    // Initialize driver      
    driver = new ChromeDriver();

    //Go to URL      
    driver.get("http://localhost:8080/IowaAir/logIn.jsp");
    driver.manage().window().maximize();

    driver.findElement(By.xpath("/html/body/div[2]/form/input[1]")).sendKeys("beer@iowaair.net");
    driver.findElement(By.xpath("/html/body/div[2]/form/input[2]")).sendKeys("password");
    driver.findElement(By.xpath("/html/body/div[2]/form/input[3]")).click();

    String url = driver.getCurrentUrl();
    if (url.equals("http://localhost:8080/IowaAir/home.jsp")) {
        System.out.println("Login Successful");
        driver.findElement(By.xpath("//*[@id=\"radioButtons\"]/input[3]")).click();
        driver.findElement(By.xpath("//*[@id=\"multiAddFlight\"]")).click();
        Select origin1 = new Select(driver.findElement(By.xpath("//*[@id=\"form2\"]/div[2]/select[1]")));
        origin1.selectByVisibleText("ORD");
        Select destination1 = new Select(driver.findElement(By.xpath("//*[@id=\"form2\"]/div[2]/select[2]")));
        destination1.selectByVisibleText("SFO");
        driver.findElement(By.xpath("//*[@id=\"multiFlightDepart1\"]")).sendKeys("05/05/2017");
        Select origin2 = new Select(driver.findElement(By.xpath("//*[@id=\"form2\"]/div[3]/select[1]")));
        origin2.selectByVisibleText("SFO");
        Select destination2 = new Select(driver.findElement(By.xpath("//*[@id=\"form2\"]/div[3]/select[2]")));
        destination2.selectByVisibleText("ATL");
        driver.findElement(By.xpath("//*[@id=\"multiFlightDepart2\"]")).sendKeys("05/05/2017");
        Select origin3 = new Select(driver.findElement(By.xpath("//*[@id=\"flight3div\"]/select[1]")));
        origin3.selectByVisibleText("ATL");
        Select destination3 = new Select(driver.findElement(By.xpath("//*[@id=\"flight3div\"]/select[2]")));
        destination3.selectByVisibleText("IFC");
        driver.findElement(By.xpath("//*[@id=\"multiFlightDepart3\"]")).sendKeys("05/05/2017");
        driver.findElement(By.xpath("//*[@id=\"form2\"]/div[7]/button")).click();
        url = driver.getCurrentUrl();//from w  w w . j  a  v a  2  s  .c  o m
        if (url.equals(
                "http://localhost:8080/IowaAir/searchResultsMultiCity.jsp?num_of_passengers=1&multiFlightOrigin1=ORD&multiFlightDestination1=SFO&multiFlightDepart1=2017-05-05&multiFlightOrigin2=SFO&multiFlightDestination2=ATL&multiFlightDepart2=2017-05-05&multiFlightOrigin3=ATL&multiFlightDestination3=IFC&multiFlightDepart3=2017-05-05&multiFlightOrigin4=null&multiFlightDestination4=null&multiFlightDepart4=")) {
            System.out.println("Multi City Flight search was successful");
            driver.findElement(By.xpath("//*[@id=\"inner\"]/tbody/tr[2]/td[10]/form/input[3]")).click();
            url = driver.getCurrentUrl();
            if (url.equals(
                    "http://localhost:8080/IowaAir/searchResultsMultiCity.jsp?flight_id1=32&flight_id2=54")) {
                System.out.println("First Selection successful");
                driver.findElement(By.xpath("//*[@id=\"inner\"]/tbody/tr[2]/td[10]/form/input[2]")).click();
                url = driver.getCurrentUrl();
                if (url.equals("http://localhost:8080/IowaAir/searchResultsMultiCity.jsp?flight_id1=29")) {
                    System.out.println("Second Selection successful");
                    driver.findElement(By.xpath("//*[@id=\"inner\"]/tbody/tr[2]/td[10]/form/input[3]")).click();
                    url = driver.getCurrentUrl();
                    if (url.equals("http://localhost:8080/IowaAir/confirmBookingMultiCity.jsp")) {
                        System.out.println("Third Selection successful");
                        driver.findElement(By.xpath("/html/body/div[2]/b/form[1]/p/input")).click();
                        url = driver.getCurrentUrl();
                        if (url.equals("http://localhost:8080/IowaAir/passengerInfo.jsp")) {
                            System.out.println("Booking Confirmed successful");
                            driver.findElement(By.xpath("/html/body/div[2]/form/input[1]")).sendKeys("Nick");
                            driver.findElement(By.xpath("/html/body/div[2]/form/input[2]")).sendKeys("Kutsch");
                            Select seatNum = new Select(
                                    driver.findElement(By.xpath("/html/body/div[2]/form/select")));
                            seatNum.selectByIndex(2);
                            driver.findElement(By.xpath("/html/body/div[2]/form/input[3]")).sendKeys("1");
                            driver.findElement(By.xpath("/html/body/div[2]/form/input[5]")).click();
                            url = driver.getCurrentUrl();
                            if (url.equals("http://localhost:8080/IowaAir/purchaseFlight.jsp")) {
                                System.out.println("Passenger Info Page successful");
                                driver.findElement(By.xpath("/html/body/div[2]/form/input[13]"))
                                        .sendKeys("0123456789");
                                Select month = new Select(
                                        driver.findElement(By.xpath("/html/body/div[2]/form/select[1]")));
                                month.selectByVisibleText("05");
                                Select year = new Select(
                                        driver.findElement(By.xpath("/html/body/div[2]/form/select[2]")));
                                year.selectByVisibleText("20");
                                driver.findElement(By.xpath("/html/body/div[2]/form/input[14]"))
                                        .sendKeys("123");
                                driver.findElement(By.xpath("/html/body/div[2]/form/input[15]")).click();
                                url = driver.getCurrentUrl();
                                if (url.equals("http://localhost:8080/IowaAir/userFlightHistory.jsp")) {
                                    System.out.println("Purchase successful");

                                } else {
                                    System.out.println("Purchase failed");
                                }
                            } else {
                                System.out.println("Passenger Info Page Failed");
                            }

                        } else {
                            System.out.println("Booking Confirmed failed");
                        }
                    } else {
                        System.out.println("Third Selection failed");
                    }
                } else {
                    System.out.println("Second Selection failed");
                }
            } else {
                System.out.println("First Slection failed");
            }

        } else {
            System.out.println("Multi City Flight search failed");
        }

    } else {
        System.out.println("Login failed");
    }
    driver.quit();
}

From source file:testing.OneWaySearchTest.java

public static void main(String[] args) {
    System.setProperty("webdriver.chrome.driver", "web/WEB-INF/chromedriver.exe");
    // TODO code application logic here
    // Initialize driver      
    driver = new ChromeDriver();

    //Go to URL      
    driver.get("http://localhost:8080/IowaAir/logIn.jsp");
    driver.manage().window().maximize();

    driver.findElement(By.xpath("/html/body/div[2]/form/input[1]")).sendKeys("beer@iowaair.net");
    driver.findElement(By.xpath("/html/body/div[2]/form/input[2]")).sendKeys("password");
    driver.findElement(By.xpath("/html/body/div[2]/form/input[3]")).click();

    String url = driver.getCurrentUrl();
    if (url.equals("http://localhost:8080/IowaAir/home.jsp")) {
        //Select One Way
        driver.findElement(By.xpath("//*[@id=\"radioButtons\"]/input[2]")).click();
        Select origin = new Select(driver.findElement(By.xpath("//*[@id=\"form1\"]/select[1]")));
        origin.selectByVisibleText("IFC");
        Select destination = new Select(driver.findElement(By.xpath("//*[@id=\"form1\"]/select[2]")));
        destination.selectByVisibleText("ORD");
        driver.findElement(By.xpath("//*[@id=\"form1\"]/input[1]")).sendKeys("05/05/2017");
        driver.findElement(By.xpath("//*[@id=\"form1\"]/div/button")).click();

        url = driver.getCurrentUrl();/*from  www  . j a v a 2 s.  c  om*/
        if (url.equals(
                "http://localhost:8080/IowaAir/searchResults.jsp?origin=IFC&destination=ORD&d_date=2017-05-05&r_date=&num_of_passengers=1")) {
            System.out.println("Search was successful");
            driver.findElement(By.xpath("//*[@id=\"inner\"]/tbody/tr[2]/td[10]/form/input[2]")).click();
            url = driver.getCurrentUrl();
            if (url.equals("http://localhost:8080/IowaAir/confirmBooking.jsp")) {
                System.out.println("Selection successful");
                driver.findElement(By.xpath("/html/body/div[2]/b/form[2]/p/input")).click();
                url = driver.getCurrentUrl();
                if (url.equals("http://localhost:8080/IowaAir/passengerInfo.jsp")) {
                    System.out.println("Confirmed booking successful");
                    driver.findElement(By.xpath("/html/body/div[2]/form/input[1]")).sendKeys("Nick");
                    driver.findElement(By.xpath("/html/body/div[2]/form/input[2]")).sendKeys("Kutsch");
                    Select seatNum = new Select(driver.findElement(By.xpath("/html/body/div[2]/form/select")));
                    seatNum.selectByIndex(2);
                    driver.findElement(By.xpath("/html/body/div[2]/form/input[3]")).sendKeys("1");
                    driver.findElement(By.xpath("/html/body/div[2]/form/input[5]")).click();
                    url = driver.getCurrentUrl();

                    if (url.equals("http://localhost:8080/IowaAir/purchaseFlight.jsp")) {
                        System.out.println("Passenger Info successful");
                        driver.findElement(By.xpath("/html/body/div[2]/form/input[5]")).sendKeys("0123456789");
                        Select month = new Select(
                                driver.findElement(By.xpath("/html/body/div[2]/form/select[1]")));
                        month.selectByVisibleText("11");
                        Select year = new Select(
                                driver.findElement(By.xpath("/html/body/div[2]/form/select[2]")));
                        year.selectByVisibleText("20");
                        driver.findElement(By.xpath("/html/body/div[2]/form/input[6]")).sendKeys("123");
                        driver.findElement(By.xpath("/html/body/div[2]/form/input[7]")).click();
                        url = driver.getCurrentUrl();
                        if (url.equals("http://localhost:8080/IowaAir/userFlightHistory.jsp")) {
                            System.out.println("Purchase successful");
                        } else {
                            System.out.println("Purchase failed");
                        }
                    } else {
                        System.out.println("Passenger Info failed");
                    }
                } else {
                    System.out.println("Confirmed booking failed");
                }

            } else {
                System.out.println("Second Selection failed");
            }
        } else {
            System.out.println("Search Failed");
        }

    } else {
        System.out.println("Login Failed");
    }
    driver.quit();
}

From source file:testing.RoundTripSearchTest.java

public static void main(String[] args) {
    System.setProperty("webdriver.chrome.driver", "web/WEB-INF/chromedriver.exe");
    // TODO code application logic here
    // Initialize driver      
    driver = new ChromeDriver();

    //Go to URL      
    driver.get("http://localhost:8080/IowaAir/logIn.jsp");
    driver.manage().window().maximize();

    driver.findElement(By.xpath("/html/body/div[2]/form/input[1]")).sendKeys("beer@iowaair.net");
    driver.findElement(By.xpath("/html/body/div[2]/form/input[2]")).sendKeys("password");
    driver.findElement(By.xpath("/html/body/div[2]/form/input[3]")).click();

    String url = driver.getCurrentUrl();
    if (url.equals("http://localhost:8080/IowaAir/home.jsp")) {
        System.out.println("Login Successful");
        //Select round trip
        driver.findElement(By.xpath("//*[@id=\"radioButtons\"]/input[1]")).click();
        Select origin = new Select(driver.findElement(By.xpath("//*[@id=\"form1\"]/select[1]")));
        origin.selectByVisibleText("IFC");
        Select destination = new Select(driver.findElement(By.xpath("//*[@id=\"form1\"]/select[2]")));
        destination.selectByVisibleText("ORD");
        driver.findElement(By.xpath("//*[@id=\"form1\"]/input[1]")).sendKeys("05/05/2017");
        driver.findElement(By.xpath("//*[@id=\"returnDate\"]")).sendKeys("05/05/2017");
        driver.findElement(By.xpath("//*[@id=\"form1\"]/div/button")).click();

        url = driver.getCurrentUrl();// w  w  w  .ja  va  2s .  c  o  m
        if (url.equals(
                "http://localhost:8080/IowaAir/searchResults.jsp?origin=IFC&destination=ORD&d_date=2017-05-05&r_date=2017-05-05&num_of_passengers=1")) {
            System.out.println("Search was successful");
            driver.findElement(By.xpath("//*[@id=\"inner\"]/tbody/tr[2]/td[10]/form/input[3]")).click();
            url = driver.getCurrentUrl();
            if (url.equals("http://localhost:8080/IowaAir/searchResults.jsp?flight_id1=54&flight_id2=55")) {
                System.out.println("First selection successful");
                driver.findElement(By.xpath("//*[@id=\"inner\"]/tbody/tr[2]/td[10]/form/input[2]")).click();
                url = driver.getCurrentUrl();
                if (url.equals("http://localhost:8080/IowaAir/confirmBooking.jsp")) {
                    System.out.println("Second selection successful");
                    driver.findElement(By.xpath("/html/body/div[2]/b/form[1]/p/input")).click();
                    url = driver.getCurrentUrl();
                    if (url.equals("http://localhost:8080/IowaAir/passengerInfo.jsp")) {
                        System.out.println("Confirmed Booking successful");
                        driver.findElement(By.xpath("/html/body/div[2]/form/input[1]")).sendKeys("Nick");
                        driver.findElement(By.xpath("/html/body/div[2]/form/input[2]")).sendKeys("Kutsch");
                        Select seatNum = new Select(
                                driver.findElement(By.xpath("/html/body/div[2]/form/select")));
                        seatNum.selectByIndex(2);
                        driver.findElement(By.xpath("/html/body/div[2]/form/input[3]")).sendKeys("1");
                        driver.findElement(By.xpath("/html/body/div[2]/form/input[5]")).click();
                        url = driver.getCurrentUrl();

                        if (url.equals("http://localhost:8080/IowaAir/purchaseFlight.jsp")) {
                            System.out.println("Passenger Info Page successful");
                            driver.findElement(By.xpath("/html/body/div[2]/form/input[9]"))
                                    .sendKeys("0123456789");
                            Select month = new Select(
                                    driver.findElement(By.xpath("/html/body/div[2]/form/select[1]")));
                            month.selectByVisibleText("11");
                            Select year = new Select(
                                    driver.findElement(By.xpath("/html/body/div[2]/form/select[2]")));
                            year.selectByVisibleText("20");
                            driver.findElement(By.xpath("/html/body/div[2]/form/input[10]")).sendKeys("123");
                            driver.findElement(By.xpath("/html/body/div[2]/form/input[11]")).click();
                            url = driver.getCurrentUrl();
                            if (url.equals("http://localhost:8080/IowaAir/userFlightHistory.jsp")) {
                                System.out.println("Purchase successful");
                            } else {
                                System.out.println("Purchase failed");
                            }
                        } else {
                            System.out.println("Passenger Info Page Failed");
                        }
                    } else {
                        System.out.println("Confirmed booking failed");
                    }
                } else {
                    System.out.println("Second Selection failed");
                }
            } else {
                System.out.println("First selection failed");
            }
        } else {
            System.out.println("Search Failed");
        }

    } else {
        System.out.println("Login Failed");
    }
    driver.quit();
}

From source file:testing.SignUpErrorTest.java

public static void main(String[] args) {
    System.setProperty("webdriver.chrome.driver", "web/WEB-INF/chromedriver.exe");
    // TODO code application logic here
    // Initialize driver      
    driver = new ChromeDriver();

    //Go to URL      
    driver.get("http://localhost:8080/IowaAir/signUp.jsp");
    driver.manage().window().maximize();

    driver.findElement(By.xpath("/html/body/div[2]/div/form/input[1]")).sendKeys("Billy");
    driver.findElement(By.xpath("/html/body/div[2]/div/form/input[2]")).sendKeys("Bob");
    driver.findElement(By.xpath("/html/body/div[2]/div/form/input[6]")).sendKeys("04/26/1990");
    driver.findElement(By.xpath("/html/body/div[2]/div/form/input[7]")).sendKeys("nickkutsch3@gmail.com");
    driver.findElement(By.xpath("/html/body/div[2]/div/form/input[8]")).sendKeys("Hawks");
    driver.findElement(By.xpath("/html/body/div[2]/div/form/input[9]")).sendKeys("Hawkeyes123");
    driver.findElement(By.xpath("/html/body/div[2]/div/form/input[10]")).click();

    String url = driver.getCurrentUrl();
    if (url.equals("http://localhost:8080/IowaAir/home.jsp")) {
        System.out.println("Sign up Successful");
    } else {//from   w  ww.  j  a  va  2s  .  c om
        System.out.println("Sign up failed");
    }
    driver.quit();
}

From source file:testng.tests.tests.java

@BeforeTest
public void setUpTest() throws Exception {
    System.setProperty("webdriver.chrome.driver", "//usr//share//rats//chromedriver");
    driver = new ChromeDriver();
    driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
    driver.get("http://www.amazon.co.uk");

}

From source file:testrunner.orchestrator.TestOrchestrator.java

License:Apache License

public static void main(String[] args) throws Exception {
    String xmlPath = (args != null && args.length > 0 ? args[0] : null);
    if (xmlPath == null || xmlPath.trim().equals("")) {
        xmlPath = "/Users/daponn/personals/2014/selenium-Priya/testXML/TestHomePageAndSearch.xml";
    }/* w ww  . j  av a  2  s . c o  m*/

    if (xmlPath == null || xmlPath.trim().equals("")) {
        System.out.println("No XML File is passed. Please pass an XML File to run the test");
        System.exit(0);
    }
    Test test = TestBuilder.buildTest(xmlPath);

    TestConfig testConfig = test.getTestConfig();
    System.out.println("The Test Object is :" + test);
    if (test == null || test.getFlows() == null || test.getFlows().isEmpty()) {
        System.out.println("The XML :" + xmlPath
                + " Seems to have no Flows defined. Please specify a Valid Test with Flows");
        System.exit(0);
    }
    int users = test.getUsers();
    if (users <= 0) {
        users = 1;
    }
    ExecutorService fixedPoolExecutor = Executors.newFixedThreadPool(users);

    WebDriver ffDriver = null;
    WebDriver chromeDriver = null;
    WebDriver ieDriver = null;
    System.out.println("The testConfig is " + testConfig);
    List<Future<TestResult>> testResults = new ArrayList<Future<TestResult>>();
    for (int user = 1; user <= users; user++) {

        if (testConfig.isEnableFireFox()) {

            FirefoxProfile seleniumProfile = null;
            ProfilesIni allProfile = new ProfilesIni();
            seleniumProfile = allProfile.getProfile("default");
            ffDriver = new FirefoxDriver(seleniumProfile);

            TestExecutor testExecutor = new TestExecutor(ffDriver, "FFTestUser:" + user);

            if (test.isResetCookies()) {
                ffDriver.manage().deleteAllCookies();
            }
            testExecutor.setCurrentTestToExecute(test);
            Future<TestResult> result = fixedPoolExecutor.submit(testExecutor);
            testResults.add(result);

        }
        if (testConfig.isEnableChrome()) {

            System.out.println("The Chrome path is " + testConfig.getChromePath());
            if (testConfig.getChromePath() != null) {
                System.setProperty("webdriver.chrome.driver", testConfig.getChromePath().trim());
            } else {
                System.setProperty("webdriver.chrome.driver", "c:\\Work\\Tools\\Selenium\\chromedriver.exe");
            }
            chromeDriver = new ChromeDriver();
            TestExecutor testExecutor = new TestExecutor(chromeDriver, "ChromeTestUser:" + user);
            if (test.isResetCookies()) {
                chromeDriver.manage().deleteAllCookies();
            }
            testExecutor.setCurrentTestToExecute(test);
            Future<TestResult> result = fixedPoolExecutor.submit(testExecutor);
            testResults.add(result);

        }
        if (testConfig.isEnableIE()) {
            System.setProperty("webdriver.ie.driver", testConfig.getIePath());
            DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
            caps.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, false);
            caps.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, "about:blank");
            // caps.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS,
            // true);
            ieDriver = new InternetExplorerDriver(caps);
            TestExecutor testExecutor = new TestExecutor(ieDriver, "IETestUser:" + user);
            if (test.isResetCookies()) {
                ieDriver.manage().deleteAllCookies();
            }
            testExecutor.setCurrentTestToExecute(test);
            Future<TestResult> result = fixedPoolExecutor.submit(testExecutor);
            testResults.add(result);

        }
    }
    for (Future<TestResult> result : testResults) {
        TestResult testResult = result.get();
        System.out.println("Test Result is " + testResult);
    }
    fixedPoolExecutor.shutdown();
    System.out.println("The test is completed ");
}

From source file:tests.FunctionalTests.java

@BeforeTest
public void openBrowser() {
    System.setProperty("webdriver.chrome.driver",
            "C:/Users/vgjoze01/Downloads/chromedriver_win32/chromedriver.exe");
    //driver = new FirefoxDriver();
    driver = new ChromeDriver();
    driver.manage().deleteAllCookies();/*from  w w w.j a  va  2s.  com*/
}