Example usage for org.openqa.selenium By xpath

List of usage examples for org.openqa.selenium By xpath

Introduction

In this page you can find the example usage for org.openqa.selenium By xpath.

Prototype

public static By xpath(String xpathExpression) 

Source Link

Usage

From source file:OrdenFabricacionTest.java

@Test
public void testDeleteProveedor() throws Exception {
    /**//from w w w. j  av  a  2 s . co  m
     * Se hace clic en el vinculo "Delete" del primer elemento de la lista
     * de sports
     */
    driver.findElement(By.linkText("Eliminar")).click();
    Thread.sleep(2000);
    /**
     * Se verifica que en la lista el elemento halla desaparecido. Si
     * existe, hubo un error.
     */
    try {
        List<WebElement> table = driver
                .findElements(By.xpath("//table[contains(@class,'table striped')]/tbody/tr"));
        boolean fail = false;

        for (WebElement webElement : table) {
            List<WebElement> elems = webElement.findElements(By.xpath("td"));

            if (elems.get(0).getText().equals(name2)
                    && Integer.parseInt(
                            elems.get(1).getText().split("/")[0]) == (Integer.parseInt(fecha2.split("/")[0]))
                    && Integer.parseInt(
                            elems.get(1).getText().split("/")[1]) == (Integer.parseInt(fecha2.split("/")[1]))
                    && Integer.parseInt(
                            elems.get(1).getText().split("/")[2]) == (Integer.parseInt(fecha2.split("/")[2]))
                    && elems.get(2).getText().equals(cantidad2) && elems.get(3).getText().equals(estado2)
                    && elems.get(4).getText().equals(nombreProducto2)) {
                fail = true;
            }

        }

        WebElement dialog = driver.findElement(By.xpath("//div[contains(@style,'display: block;')]"));
        assertTrue(dialog != null && !fail);
    } catch (Exception e) {
        assertTrue(true);
    }

}

From source file:OrdenFabricacionTest.java

@Test
public void testListProveedores() throws Exception {
    /**/*from   w  ww.ja  va  2  s.  com*/
     * Se crea un deporte con el test createSport
     */
    testCreateProveedor();

    /**
     * Se hace clic en el botn "refresh" del toolbar para obtener la lista.
     */
    driver.findElement(By.xpath("//button[contains(@id,'refreshButton')]")).click();
    Thread.sleep(2000);
    /**
     * Se verifica que el elemento creado anteriormente existe en la lista.
     */
    List<WebElement> table = driver
            .findElements(By.xpath("//table[contains(@class,'table striped')]/tbody/tr"));
    boolean fail = false;
    for (WebElement webElement : table) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));

        if (elems.get(0).getText().equals(name1)
                && Integer.parseInt(
                        elems.get(1).getText().split("/")[0]) == (Integer.parseInt(fecha1.split("/")[0]))
                && Integer.parseInt(
                        elems.get(1).getText().split("/")[1]) == (Integer.parseInt(fecha1.split("/")[1]))
                && Integer.parseInt(
                        elems.get(1).getText().split("/")[2]) == (Integer.parseInt(fecha1.split("/")[2]))
                && elems.get(2).getText().equals(cantidad1) && elems.get(3).getText().equals(estado1)
                && elems.get(4).getText().equals(nombreProducto1)) {
            fail = true;
        }

    }
    assertTrue(fail);
}

From source file:ToTrainingFolder.java

public static void main(String[] args) throws IOException {

    System.setProperty("webdriver.ie.driver",
            "C:\\Users\\Colin Cook\\Desktop\\Opstar Training Folder\\IEDriverServer.exe");
    WebDriver driver = new InternetExplorerDriver();

    driver.get("http://10.0.1.53/opstar_test/");

    out.println("Launching Internet Explorer browser..");
    driver.manage().window().maximize();
    try {// w w  w.  j  av  a 2s . c  o  m
        Thread.sleep(1000); // pauses for 1 second
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    out.println("The title of the page being tested is:  " + driver.getTitle());

    WebElement acknowledge = driver
            .findElement(By.xpath("html/body/div[5]/div[1]/div[2]/div[2]/div[1]/div/div[2]/center/a"));
    acknowledge.click(); //first popup when you go on site
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement applications = driver.findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/a"));
    //driver.findElement(By.linkText("Training Folder"));
    System.out.println(applications.getText());
    applications.click();

    WebElement toTools = driver
            .findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/ul/li[2]/a"));
    toTools.click();
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement traingFolder = driver
            .findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/ul/li[2]/ul/li/a"));
    traingFolder.click();
    System.out.println("The Training Folder has been selected");
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement closeBox = driver.findElement(By.id("cboxClose"));
    closeBox.click(); //clicks second popup acknolwedge box
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement textBox = driver.findElement(By
            .xpath("html/body/div[3]/div[4]/div[2]/div/div[1]/div/div[2]/div/form/div/div/span/span[1]/span"));
    textBox.click();
    textBox.sendKeys("ken");
    textBox.sendKeys(Keys.ENTER);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    /***************
     THIS IS WHERE THE QUALIFICATIONS FOLDER STARTS
     ******************/

    WebElement image1 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[1]/div[1]/span/a/img"));
    image1.click();
    image1.sendKeys(Keys.ESCAPE);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement table1 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[1]/div[2]/input"));
    table1.clear();
    table1.sendKeys("Testing table 1, Opstar Test");
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement date1 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[1]/div[3]/input"));
    date1.click();
    date1.clear();
    date1.sendKeys("12/25/2016");
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    // WebElement save = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[1]/div[5]/span[1]/i"));
    //save.click();

    WebElement image2 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[3]/div[1]/span/a/img"));
    image2.click();
    image2.sendKeys(Keys.ESCAPE);
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement title2 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[3]/div[2]/input"));
    title2.clear();
    title2.sendKeys("Testing table 2, Opstar test 2");
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement date2 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[3]/div[3]/input"));
    date2.click();
    date2.clear();
    date2.sendKeys("01/01/2017");
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    // WebElement save2 = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[3]/div[5]/span[1]/i"));
    //save2.click();

    WebElement closeQualifications = driver
            .findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[1]/div/a[2]"));
    closeQualifications.click();

    System.out.println("The Qualifications folder has been tested");

    /***************
     THIS IS WHERE THE DESIGNATIONS FOLDER STARTS
     ******************/

    WebElement Designations = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[2]/table/tbody/tr/td[1]/span/a/img"));
    Designations.click();
    Designations.sendKeys(Keys.ESCAPE);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement DesignationsTitle = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[2]/table/tbody/tr/td[2]/input"));
    DesignationsTitle.clear();
    DesignationsTitle.sendKeys("Testing the Desiganations title box, Opstar Test");

    WebElement DesignationsIssue = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[2]/table/tbody/tr/td[3]/input"));

    DesignationsIssue.clear();
    DesignationsIssue.sendKeys("03/24/2017");
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    // WebElement saveDesignations = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[2]/table/tbody/tr/td[5]/span[1]/i"));
    //saveDesignations.click();

    WebElement closeDesignations = driver
            .findElement(By.xpath(".//*[@id='student_folder_wrapper']/div[2]/div[1]/div/div[1]/div/a[2]"));
    closeDesignations.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    System.out.println("The Designations box has been tested");

    /***************
     THIS IS WHERE THE WAIVERS FOLDER STARTS
     ******************/

    WebElement waivers = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[1]/div/a[2]"));
    waivers.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement waiversFile = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[2]/table/tbody/tr/td[1]/span/a/img"));
    waiversFile.click();
    waiversFile.sendKeys(Keys.ESCAPE);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement waiversTitle = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[2]/table/tbody/tr/td[2]/input"));
    waiversTitle.clear();
    waiversTitle.sendKeys("Testing the Waivers folder, Opstar test");

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement issueDateWaivers = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[2]/table/tbody/tr/td[3]/input"));
    issueDateWaivers.clear();
    issueDateWaivers.sendKeys("01/16/2016");

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    //WebElement saveWaivers = driver.findElement(By.xpath(".//*[@id='student_folder_wrapper']/div[2]/div[2]/div/div[2]/table/tbody/tr/td[5]/span[1]/i"));
    //saveWaivers.click();

    WebElement closeWaivers = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[1]/div/a[2]"));
    closeWaivers.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    System.out.println("The waivers folder has been tested");
    /***************
     THIS IS WHERE THE PROFESSIONAL LICENSES FOLDER STARTS
     ******************/

    WebElement proLicensesCert = driver
            .findElement(By.xpath(".//*[@id='student_folder_wrapper']/div[2]/div[3]/div/div[1]/div/a[2]"));
    proLicensesCert.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement imagePro = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[2]/table/tbody/tr/td[1]/span/a/img"));
    imagePro.click();
    imagePro.sendKeys(Keys.ESCAPE);

    WebElement proTitle = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[2]/table/tbody/tr/td[2]/input"));
    proTitle.clear();
    proTitle.sendKeys("OpSTAR Automation testing this title box");

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement proIssueDate = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[2]/table/tbody/tr/td[3]/input"));
    proIssueDate.clear();
    proIssueDate.sendKeys("05/04/2017");
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement proClose = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[1]/div/a[2]"));
    proClose.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    System.out.println("The professional Licenses, Certificates, Medical folder has been tested");
    /***************
     THIS IS WHERE THE FIRSTAID FOLDER STARTS
     ******************/

    WebElement firstAid = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[1]/div/a[2]"));
    firstAid.click();

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement firstAidImage = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[2]/table/tbody/tr/td[1]/span/a/img"));
    firstAidImage.click();
    firstAidImage.sendKeys(Keys.ESCAPE);

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement firstAidTitle = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[2]/table/tbody/tr/td[2]/input"));
    firstAidTitle.clear();
    firstAidTitle.sendKeys("KeyBridge automation testing using Selenium");

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement firstAidDate = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[2]/table/tbody/tr/td[3]/input"));
    firstAidDate.clear();
    firstAidDate.sendKeys("02/02/2017");
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement closeFirstAid = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[1]/div/a[2]"));
    closeFirstAid.click();
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    System.out.println("The First Aid folder has been tested");
    /***************
     THIS IS WHERE THE STAR FOLDER STARTS
     ******************/

    WebElement starOpen = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[1]/div/a[2]"));
    starOpen.click();
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    WebElement starImage1 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[1]/td[1]/span/a/img"));
    starImage1.click();
    starImage1.sendKeys(Keys.ESCAPE);

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement starTitle1 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[1]/td[2]/input"));
    starTitle1.clear();
    starTitle1.sendKeys("KeyBridge OpSTAR automation testing");

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement starIssueDate1 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[1]/td[3]/input"));
    starIssueDate1.clear();
    starIssueDate1.sendKeys("03/17/2017");

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement starTitle2 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[2]/td[2]/input"));
    starTitle2.clear();
    starTitle2.sendKeys("CPB Automation Testing");

    // WebElement starIssueDate2 = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[2]/td[3]/input"));
    // starIssueDate2.click();

    WebElement closeStarFolder = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[1]/div/a[2]"));
    closeStarFolder.click();
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    System.out.println("The Star Folder has been tested");

    /***************
     THIS IS WHERE THE TRAINING COURSES AND TESTS FOLDER STARTS
     ******************/
    WebElement openCourseAndTests = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/div/a[2]"));
    openCourseAndTests.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement lastFive = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/h4/span[2]"));
    lastFive.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement showAll = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/h4/span[3]"));
    showAll.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement closeTrainingCourse = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/div/a[2]"));
    closeTrainingCourse.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    System.out.println("The Training Courses and Tests folder has been tested");
    /***************
     THIS IS WHERE THE PROFESSIONAL DEVELOPMENT FOLDER STARTS
     ******************/

    WebElement proDevelopment = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[1]/div/a[2]"));
    proDevelopment.click();

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement proImage = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[2]/table/tbody/tr/td[1]/span/a/img"));
    proImage.click();
    proImage.sendKeys(Keys.ESCAPE);

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement proTitle2 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[2]/table/tbody/tr/td[2]/input"));
    proTitle2.clear();
    proTitle2.sendKeys("Testing the PRO Development box");

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    WebElement proDevelopmentDate = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[2]/table/tbody/tr/td[3]/input"));
    proDevelopmentDate.clear();
    proDevelopmentDate.sendKeys("03/24/2017");

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement closeProDevelopment = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[1]/div/a[2]"));
    closeProDevelopment.click();

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    System.out.println("The Professional Development / Individual Development Plan Folder has been tested");
    /***************
     THIS IS WHERE THE FLETC CERTIFICATES FOLDER STARTS
     ******************/

    WebElement fletcOpen = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[1]/div/a[2]"));
    fletcOpen.click();
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement fletcImage = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[2]/table/tbody/tr/td[1]/span/a/img"));
    fletcImage.click();
    fletcImage.sendKeys(Keys.ESCAPE);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    WebElement fletcTitle = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[2]/table/tbody/tr/td[2]/input"));
    fletcTitle.clear();
    fletcTitle.sendKeys("Testing the FLETC Certificates folder");
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement fletcDate = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[2]/table/tbody/tr/td[3]/input"));
    fletcDate.clear();
    fletcDate.sendKeys("03/24/2017");
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement closeFLETC = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[1]/div/a[2]"));
    closeFLETC.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    System.out.println("The FLETC Certificates Folder has been tested");
    /***************
     THIS IS WHERE THE MISCELLANEOUS CERTIFICATES FOLDER STARTS
     ******************/

    WebElement openMisc = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[1]/div/a[2]"));
    openMisc.click();
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement miscImage = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[2]/table/tbody/tr/td[1]/span/a/img"));
    miscImage.click();
    miscImage.sendKeys(Keys.ESCAPE);

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    WebElement miscTitle = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[2]/table/tbody/tr/td[2]/input"));
    miscTitle.clear();
    miscTitle.sendKeys("Testing the the Misc box");

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    WebElement miscDate = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[2]/table/tbody/tr/td[3]/input"));
    miscDate.clear();
    miscDate.sendKeys("12/25/2016");

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    WebElement closeMisc = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[1]/div/a[2]"));
    closeMisc.click();
    System.out.println("The Miscellaneous folder has been tested");

    System.out.println("The Training Folder automation test has successfully passed!");

}

From source file:MobileChosenIT.java

License:Apache License

@Override
protected String getMultiplePlaceHolderText() {
    String xpath = "//div[@id='chosen_container__0_chzn']//span";

    return webDriverWait().until(presenceOfElementLocated(By.xpath(xpath))).getText();
}

From source file:MobileChosenIT.java

License:Apache License

protected void openDropDown() {
    String xpath = "//div[@id='chosen_container__0_chzn']";
    WebElement btn = webDriverWait().until(elementToBeClickable(By.xpath(xpath)));
    btn.click();//from   w  ww.  ja  va 2s .c o m

    waitUntilDropdownIsOpened();
}

From source file:MobileChosenIT.java

License:Apache License

private void closeMobileDropDown() {
    String xpath = "//div[@id='chosen_container__0_chzn']//i[@role='close']";

    WebElement closeButton = webDriverWait().until(elementToBeClickable(By.xpath(xpath)));

    closeButton.click();/*from w w  w. ja  va 2 s . c o  m*/
}

From source file:ItemTest.java

@Test
public void testCreateProveedor() throws Exception {

    /**/*from w ww  .  jav  a 2 s . co m*/
     * Comando que realiza click sobre el boton "create" del toolbar. La
     * funcin 'find' encuentra el control y posteriormente hace clic en el
     * mismo. La forma en la que se busca el control es utilizando
     * expresiones xPath ya que los id de los mismos nunca son iguales (se
     * generan con junto con el valor de componentId que vara).
     */
    driver.findElement(By.xpath("//button[contains(@id,'createButton')]")).click();

    /**
     * Comando que duerme el Thread del test por 2 segundos para dejar que
     * el efecto 'slide down' de backbone abra el formulario de createSport.
     */
    Thread.sleep(2000);

    /**
     * Comando que busca el elemento 'name' en el html actual.
     * Posteriormente limpia su contenido (comando clean).
     */
    driver.findElement(By.id("name")).clear();
    /**
     * Comando que simula la escritura de un valor en el elemento(sendKeys)
     * con el String de parmetro sobre // el elemento encontrado.
     */
    driver.findElement(By.id("name")).sendKeys(name1);

    //Comandos para llenar el campo FECHACADUCIDAD
    driver.findElement(By.id("fechaCaducidad")).clear();
    driver.findElement(By.id("fechaCaducidad")).sendKeys(fechaCaducidad1);

    //Comando para seleccionar el checkbox
    //       driver.findElement(By.id("esPerecedero")).click();

    /**
     * Comandos para llenar el campo MOTIVOINGRESO
     */
    driver.findElement(By.id("motivoIngreso")).clear();
    driver.findElement(By.id("motivoIngreso")).sendKeys(motivoIngreso1);

    /**
     * Comandos para llenar el campo MOTIVOSALIDA
     */
    driver.findElement(By.id("motivoSalid")).clear();
    driver.findElement(By.id("motivoSalid")).sendKeys(motivoSalida1);

    /**
     * Comando que encuentra y hace clic sobre el boton "Save" del toolbar
     * (una vez mas encontrado por una expresin Xpath)
     */
    driver.findElement(By.xpath("//button[contains(@id,'saveButton')]")).click();

    /**
     * Comando que duerme el thread para esperar el efecto de slide down que
     * abre la lista
     */
    Thread.sleep(2000);
    /**
     * Comando que obtiene el div azul de creacin exitosa. Si se obtiene,
     * la prueba va bien, si no, saldr un error y la prueba quedar como
     * fllida.
     */
    WebElement dialog = driver.findElement(By.xpath("//div[contains(@style,'display: block;')]"));
    /**
     * Comando que obtiene la tabla con el elemento que se cre
     * anteriormente.
     */
    List<WebElement> table = driver
            .findElements(By.xpath("//table[contains(@class,'table striped')]/tbody/tr"));
    boolean sucess = false;
    /**
     * Se itera sobre los elementos de la tabla para ver si el nuevo
     * elemento creado est en la lista
     */
    for (WebElement webElement : table) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));

        if (elems.get(0).getText().equals(name1)
                && Integer.parseInt(elems.get(1).getText().split("/")[0]) == (Integer
                        .parseInt(fechaCaducidad1.split("/")[0]))
                && Integer.parseInt(elems.get(1).getText().split("/")[1]) == (Integer
                        .parseInt(fechaCaducidad1.split("/")[1]))
                && Integer.parseInt(elems.get(1).getText().split("/")[2]) == (Integer
                        .parseInt(fechaCaducidad1.split("/")[2]))
                && elems.get(3).getText().equals(motivoIngreso1)
                && elems.get(4).getText().equals(motivoSalida1)) {
            /**
             * si se encuentra la fila, la variable 'fail' pasa a true,
             * indicando que el elemento creado esta en la lista.
             */
            sucess = true;
        }

    }
    /**
     * la prueba es exitosa si se encontr el dialogo de creacin exitosa y
     * el nuevo elemento est en la lista.
     */
    assertTrue(dialog != null && sucess);
}

From source file:ItemTest.java

@Test
public void testUpdateProveedor() throws Exception {

    /**//from ww  w . jav a2 s.  co m
     * Se hace clic en el vinculo "Edit" del primer elemento de la lista de
     * sports
     */
    driver.findElement(By.linkText("Editar")).click();
    Thread.sleep(2000);
    /**
     * Se realiza el mismo proceso de diligenciamento de los campos con los
     * cambios
     */
    driver.findElement(By.id("name")).clear();
    driver.findElement(By.id("name")).sendKeys(name2);
    driver.findElement(By.id("fechaCaducidad")).clear();
    driver.findElement(By.id("fechaCaducidad")).sendKeys(fechaCaducidad2);
    driver.findElement(By.id("motivoIngreso")).clear();
    driver.findElement(By.id("motivoIngreso")).sendKeys(motivoIngreso2);
    driver.findElement(By.id("motivoSalid")).clear();
    driver.findElement(By.id("motivoSalid")).sendKeys(motivoSalida2);

    driver.findElement(By.xpath("//button[contains(@id,'saveButton')]")).click();
    Thread.sleep(2000);
    /**
     * Se verifica que en la lista de respuesta hallan aparecido los cambios
     * en el elemento y tambin el mensaje de edicin exitosa.
     */
    WebElement dialog = driver.findElement(By.xpath("//div[contains(@style,'display: block;')]"));
    List<WebElement> table = driver
            .findElements(By.xpath("//table[contains(@class,'table striped')]/tbody/tr"));
    boolean fail = false;
    for (WebElement webElement : table) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));

        if (elems.get(0).getText().equals(name2)
                && Integer.parseInt(elems.get(1).getText().split("/")[0]) == (Integer
                        .parseInt(fechaCaducidad2.split("/")[0]))
                && Integer.parseInt(elems.get(1).getText().split("/")[1]) == (Integer
                        .parseInt(fechaCaducidad2.split("/")[1]))
                && Integer.parseInt(elems.get(1).getText().split("/")[2]) == (Integer
                        .parseInt(fechaCaducidad2.split("/")[2]))
                && elems.get(3).getText().equals(motivoIngreso2)
                && elems.get(4).getText().equals(motivoSalida2)) {
            fail = true;
        }

    }
    assertTrue(dialog != null && fail);
}

From source file:ItemTest.java

@Test
public void testDeleteProveedor() throws Exception {
    /**// ww w  .j ava  2s .co  m
     * Se hace clic en el vinculo "Delete" del primer elemento de la lista
     * de sports
     */
    driver.findElement(By.linkText("Eliminar")).click();
    Thread.sleep(2000);
    /**
     * Se verifica que en la lista el elemento halla desaparecido. Si
     * existe, hubo un error.
     */
    try {
        List<WebElement> table = driver
                .findElements(By.xpath("//table[contains(@class,'table striped')]/tbody/tr"));
        boolean fail = false;

        for (WebElement webElement : table) {
            List<WebElement> elems = webElement.findElements(By.xpath("td"));

            if (elems.get(0).getText().equals(name2)
                    && Integer.parseInt(elems.get(1).getText().split("/")[0]) == (Integer
                            .parseInt(fechaCaducidad2.split("/")[0]))
                    && Integer.parseInt(elems.get(1).getText().split("/")[1]) == (Integer
                            .parseInt(fechaCaducidad2.split("/")[1]))
                    && Integer.parseInt(elems.get(1).getText().split("/")[2]) == (Integer
                            .parseInt(fechaCaducidad2.split("/")[2]))
                    && elems.get(3).getText().equals(motivoIngreso2)
                    && elems.get(4).getText().equals(motivoSalida2)) {
                fail = true;
            }

        }

        WebElement dialog = driver.findElement(By.xpath("//div[contains(@style,'display: block;')]"));
        assertTrue(dialog != null && !fail);
    } catch (Exception e) {
        assertTrue(true);
    }

}

From source file:ItemTest.java

@Test
public void testListProveedores() throws Exception {
    /**/*from   w w  w . ja va 2s  .  c om*/
     * Se crea un deporte con el test createSport
     */
    testCreateProveedor();

    /**
     * Se hace clic en el botn "refresh" del toolbar para obtener la lista.
     */
    driver.findElement(By.xpath("//button[contains(@id,'refreshButton')]")).click();
    Thread.sleep(2000);
    /**
     * Se verifica que el elemento creado anteriormente existe en la lista.
     */
    List<WebElement> table = driver
            .findElements(By.xpath("//table[contains(@class,'table striped')]/tbody/tr"));
    boolean fail = false;
    for (WebElement webElement : table) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));

        if (elems.get(0).getText().equals(name1)
                && Integer.parseInt(elems.get(1).getText().split("/")[0]) == (Integer
                        .parseInt(fechaCaducidad1.split("/")[0]))
                && Integer.parseInt(elems.get(1).getText().split("/")[1]) == (Integer
                        .parseInt(fechaCaducidad1.split("/")[1]))
                && Integer.parseInt(elems.get(1).getText().split("/")[2]) == (Integer
                        .parseInt(fechaCaducidad1.split("/")[2]))
                && elems.get(3).getText().equals(motivoIngreso1)
                && elems.get(4).getText().equals(motivoSalida1)) {
            fail = true;
        }

    }
    assertTrue(fail);
}