Example usage for org.openqa.selenium WebElement getText

List of usage examples for org.openqa.selenium WebElement getText

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement getText.

Prototype

String getText();

Source Link

Document

Get the visible (i.e.

Usage

From source file:scormADL12.java

License:Open Source License

/**
 *  Explicit wait for element with text//  w w w .  java 2  s  . c o m
 * @param locator
 * @param text
 * @return
 */
public WebElement waitElementWithTextPresent(final By locator, final String text) {
    return new WebDriverWait(driver, 30).until(new ExpectedCondition<WebElement>() {
        @Override
        public WebElement apply(WebDriver d) {
            WebElement e = d.findElement(locator);
            String elementText = e.getText();
            if (elementText != null && elementText.contains(text)) {
                return e;
            } else {
                return null;
            }
        }
    });
}

From source file:ValidSubmission.java

public static void ThenJobsTitle_ShortDesc_FullDescIs() {
    // int j =0;//from www  .java  2s.c o  m
    // Grab the table 
    WebElement table = driver.findElement(By.id("jobListings"));

    //Get number of rows in table 
    int numOfRow = table.findElements(By.tagName("tr")).size();
    List<String> jobLinkUrl = new ArrayList(numOfRow);

    for (int j = 1; j <= (numOfRow - 2); j = (j + 2)) {

        String first_part_jobShortDesc_xpath = "//*[@id='jobListings']/tbody/tr[";
        String second_part_jobShortDesc_xpath = "]/td/span";

        String first_part_jobLinkTitle_xpath = "//*[@id='jobListings']/tbody/tr[";
        String second_part_jobLinkTitle_xpath = "]/td/a";

        String first_part_jobLinkUrl_xpath = "//*[@id='jobListings']/tbody/tr[";
        String second_part_jobLinkUrl_xpath = "]/td/a";

        WebElement webJobLinkUrl = driver
                .findElement(By.xpath(first_part_jobLinkUrl_xpath + (j + 2) + second_part_jobLinkUrl_xpath));
        jobLinkUrl.add(webJobLinkUrl.getAttribute("href"));
        //                   
        String final_jobLinkTitle_xpath = first_part_jobLinkTitle_xpath + (j + 2)
                + second_part_jobLinkTitle_xpath;
        String final_jobShortDesc_xpath = first_part_jobShortDesc_xpath + (j + 3)
                + second_part_jobShortDesc_xpath;

        WebElement webJobLinkTitle = driver.findElement(By.xpath(final_jobLinkTitle_xpath));
        String jobLinkTitle = webJobLinkTitle.getText();

        WebElement webJobShortDesc = driver.findElement(By.xpath(final_jobShortDesc_xpath));
        String jobShortDesc = webJobShortDesc.getAttribute("innerHTML");

        System.out.println("Job Title = " + jobLinkTitle);
        System.out.println();

        System.out.println("Short Description of Job = " + jobShortDesc);
        System.out.println();

        System.out.println("Link URL of Job" + jobLinkUrl);
        System.out.println();
    }

    //        // GoTo 'Full Job Description'
    for (int i = 0; i < jobLinkUrl.size(); i++) {

        driver.navigate().to(jobLinkUrl.get(i));
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        //          
        WebElement webJobFullDescData = driver
                .findElement(By.xpath("//*[@id='jobDetails']/div[2]/table/tbody/tr[1]/td"));
        String jobFullDescData = webJobFullDescData.getText();
        //     
        System.out.println("Job Full Description Data" + jobFullDescData);
        System.out.println();

    }
}

From source file:TestaCaixaDeEntrada.java

@Test(dependsOnGroups = "login", groups = "irpara")
public void testaIrPara() throws Exception {

    driver.navigate().to("http://52.1.49.37/SIAPCON_SPRINT1" + sprintNumber
            + "/ListarProcessos.jsf?(Not.Licensed.For.Production)=");

    try {/*  w w  w  . j  a  v a 2 s  .  com*/
        // div que contm a pgina atual e o total de pginas
        WebElement divPagination = driver
                .findElement(By.id("RichWidgets_wt88:wtMainContent:wtpaginacaoWidget:wtdivPagina"));

        // string separadora da contagem de pgina
        String pageSeparator = "/";

        // ndice da String separadora da contagem de pgina
        Integer separatorPosition = divPagination.getText().indexOf(pageSeparator);

        // forma a string com o total de pginas na Caixa de Entrada
        String totalPaginas = divPagination.getText().substring(separatorPosition + 1,
                divPagination.getText().length());

        // gera um inteiro dentro do intervalo de pginas que h
        Random number = new Random();
        Integer validPage = number.nextInt(Integer.parseInt(totalPaginas));
        if (validPage == 0) {
            validPage++;
        }

        // escreve o inteiro no input de paginao
        WebElement paginationInput = driver
                .findElement(By.id("RichWidgets_wt88:wtMainContent:wtpaginacaoWidget:wtirParaPaginaWidget"));
        paginationInput.clear();
        paginationInput.sendKeys(validPage.toString());

        // clica no boto ir para
        WebElement btnIrPara = driver
                .findElement(By.id("RichWidgets_wt88:wtMainContent:wtpaginacaoWidget:wt7"));
        btnIrPara.click();

        // D um tempo para as requisies Ajax terminarem em milisec impedindo o Selenium de prosseguir
        // Para o DOM terminar de ser recarregado
        Thread.sleep(60000);

        // div que contm a pgina atual e o total de pginas
        divPagination = driver
                .findElement(By.id("RichWidgets_wt88:wtMainContent:wtpaginacaoWidget:wtdivPagina"));

        // forma a string com a pgina atual
        // Pega tudo at a barra pra depois remover o que no  nmero
        totalPaginas = divPagination.getText().substring(0, separatorPosition + 1);

        // remove os espaos
        totalPaginas = totalPaginas.replaceAll(" ", "");
        // remove as barras
        totalPaginas = totalPaginas.replaceAll("/", "");
        // remove os caracteres no numricos
        totalPaginas = totalPaginas.replaceAll("[^0-9]", "");

        // compara com a pgina que foi setada no input
        if (!(validPage == Integer.parseInt(totalPaginas))) {
            Assert.fail("Nmero da pgina atual no  o mesmo setado no input de navegao de pginas");
        }
    } catch (Exception e) {
        throw (e);
    }
}

From source file:JUnitTestClass.java

@Test
public void Assert_Text() throws Exception {
    // Breaking down the selection process.

    // By xpath, id, classname, name, css, etc ...
    By locator = By.xpath("//div[5]/div/p[3]");

    // Stored in webelement.
    WebElement element = driver.findElement(locator);

    // Storing the target text.
    String text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed augue tellus, consectetur sed ante ut, tincidunt convallis nunc.";

    // Asserting they are the same.
    assertEquals(text, element.getText());
}

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.  ja va 2  s. 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:StoryKeyboardShortcutTests.java

@Test
public void storyFirstTest() throws InterruptedException {

    //1. Go to story site
    driver.get(/*from   w w  w  . j  ava2s  .  c  om*/
            "http://tanveer-pc:9724/web/story/story.html?debug&storyhub=tanveer-pc&gh=Guest/@tanveer-pc&pilot=tanveer-pc&preview=tanveer-pc&mediaservice=tanveer-pc");
    //driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

    WebDriverWait wait = new WebDriverWait(driver, 15);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(
            "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']")));

    //2. Close the license popup
    WebElement okButton = driver.findElement(By.cssSelector(
            "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']"));
    okButton.click();

    //Click on Media tab
    WebElement uploadButton = driver.findElement(
            By.xpath("html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[1]/div[1]/div/table/tbody/tr/td"));
    uploadButton.click();

    //Click on video tab
    WebElement videoTab = driver.findElement(By.xpath(
            "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[1]/div/div/div/table[1]/tbody[2]/tr[1]/td[1]/div/div/div[2]"));
    videoTab.click();
    WebElement searchText = driver.findElement(By.id("isc_30"));
    searchText.sendKeys("SSS_2477_01.mov");

    Thread.sleep(5000);
    WebElement selectVideo = driver.findElement(By.xpath(
            "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div[1]/div[3]"));

    selectVideo.click();

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

    Thread.sleep(2000);
    WebElement timeLine = driver.findElement(By.cssSelector("svg[id=multimedia_ClearInOut]"));
    timeLine.click();

    Thread.sleep(2000);
    int xp1 = 0;
    WebElement testtimecode1 = driver.findElement(By.xpath("//*[contains(text(),'00:0" + xp1 + ":')]"));
    final String starttime = testtimecode1.getText();

    Actions action = new Actions(driver);
    action.sendKeys(Keys.SPACE).build().perform();
    System.out.println(testtimecode1.getText());

    int ourtime = 9000;
    Thread.sleep(ourtime);
    int xp = (ourtime - 1000) / 1000;
    action.sendKeys(Keys.SPACE).build().perform();
    Thread.sleep(2000);

    timeLine.click();
    Thread.sleep(2000);
    WebElement testtimecode = driver.findElement(By.xpath("//*[contains(text(),'00:0" + xp + ":')]"));

    System.out.println(testtimecode.getText());
    System.out.println(testtimecode1.getText());

    Assert.assertNotEquals(testtimecode.getText(), starttime);
    //Assert.assertNotEquals("111", "1");

}

From source file:StoryKeyboardShortcutTests.java

@Test
public void storyKeyboardFrameForward() throws InterruptedException {

    //a. Launch story in firefox
    driver.get(/*w w  w.j  a v a2  s .c  o  m*/
            "http://tanveer-pc:9724/web/story/story.html?debug&storyhub=tanveer-pc&gh=Guest/@tanveer-pc&pilot=tanveer-pc&preview=tanveer-pc&mediaservice=tanveer-pc");
    //driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

    WebDriverWait wait = new WebDriverWait(driver, 15);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(
            "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']")));

    //Close the license popup
    WebElement okButton = driver.findElement(By.cssSelector(
            "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']"));
    okButton.click();

    //Click on Media tab
    WebElement uploadButton = driver.findElement(
            By.xpath("html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[1]/div[1]/div/table/tbody/tr/td"));
    uploadButton.click();

    //From storytab double click on story named 'storytest'
    Thread.sleep(2000);
    WebElement storytest = driver.findElement(By.xpath(
            "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div/div[3]"));
    storytest.click();
    WebElement storytest1 = driver.findElement(By.xpath(
            "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div/div[3]"));

    storytest1.click();
    storytest1.click();

    Thread.sleep(3000);
    //Select the video element in timeline div[class="thumbnailStrip"]
    WebElement timelinebar = driver.findElement(By.cssSelector("div[class='thumbnailStrip']"));
    timelinebar.click();

    Thread.sleep(2000);

    WebElement timebarnumber = driver.findElement(
            By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']"));
    final String timevalue = timebarnumber.getText();

    WebElement timebarnumber1 = driver.findElement(
            By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']"));
    final String timevalue1 = timebarnumber.getText();

    System.out.println(timevalue);
    Thread.sleep(2000);
    Actions action = new Actions(driver);
    action.sendKeys(Keys.DECIMAL).build().perform();

    WebElement timebarnumber2 = driver.findElement(
            By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']//small"));
    final String timevalue2 = timebarnumber.getText();

    final String firsttime = (timevalue1.substring(timevalue2.lastIndexOf(":") + 1));
    int timer1 = Integer.parseInt(firsttime);

    final String secondtime = (timevalue2.substring(timevalue2.lastIndexOf(":") + 1));
    int timer2 = Integer.parseInt(secondtime);

    System.out.println(timer1);
    System.out.println(timer2);
    Assert.assertEquals(timer1 + 1, timer2);

}

From source file:StoryKeyboardShortcutTests.java

@Test
public void storyKeyboardFrameBackward() throws InterruptedException {
    //a. Launch story in firefox
    driver.get(/*  w  w w  .  j a  v  a 2 s . c  o  m*/
            "http://tanveer-pc:9724/web/story/story.html?debug&storyhub=tanveer-pc&gh=Guest/@tanveer-pc&pilot=tanveer-pc&preview=tanveer-pc&mediaservice=tanveer-pc");
    //driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

    WebDriverWait wait = new WebDriverWait(driver, 15);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(
            "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']")));

    //Close the license popup
    WebElement okButton = driver.findElement(By.cssSelector(
            "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']"));
    okButton.click();

    //Click on Media tab
    WebElement uploadButton = driver.findElement(
            By.xpath("html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[1]/div[1]/div/table/tbody/tr/td"));
    uploadButton.click();

    //From storytab double click on story named 'storytest'
    Thread.sleep(2000);
    WebElement storytest = driver.findElement(By.xpath(
            "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div/div[3]"));
    storytest.click();
    WebElement storytest1 = driver.findElement(By.xpath(
            "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div/div[3]"));

    storytest1.click();
    storytest1.click();

    Thread.sleep(3000);
    //Select the video element in timeline div[class="thumbnailStrip"]
    WebElement timelinebar = driver.findElement(By.cssSelector("div[class='thumbnailStrip']"));
    timelinebar.click();

    Thread.sleep(2000);

    WebElement timebarnumber = driver.findElement(
            By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']"));
    final String timevalue = timebarnumber.getText();

    WebElement timebarnumber1 = driver.findElement(
            By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']"));
    final String timevalue1 = timebarnumber.getText();

    System.out.println(timevalue);
    Thread.sleep(2000);
    Actions action = new Actions(driver);
    action.sendKeys(Keys.SEPARATOR).build().perform();

    WebElement timebarnumber2 = driver.findElement(
            By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']//small"));
    final String timevalue2 = timebarnumber.getText();

    final String firsttime = (timevalue1.substring(timevalue2.lastIndexOf(":") + 1));
    int timer1 = Integer.parseInt(firsttime);

    final String secondtime = (timevalue2.substring(timevalue2.lastIndexOf(":") + 1));
    int timer2 = Integer.parseInt(secondtime);

    System.out.println(timer1);
    System.out.println(timer2);
    Assert.assertEquals(timer1 - 1, timer2);

}

From source file:StoryKeyboardShortcutTests.java

@Test
public void storyKeyDelete() throws InterruptedException {

    //a. Launch story in firefox
    driver.get(//from ww  w.j  av  a  2  s.c om
            "http://tanveer-pc:9724/web/story/story.html?debug&storyhub=tanveer-pc&gh=Guest/@tanveer-pc&pilot=tanveer-pc&preview=tanveer-pc&mediaservice=tanveer-pc");
    //driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

    WebDriverWait wait = new WebDriverWait(driver, 15);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(
            "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']")));

    //Close the license popup
    WebElement okButton = driver.findElement(By.cssSelector(
            "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']"));
    okButton.click();

    //Click on Media tab
    WebElement uploadButton = driver.findElement(
            By.xpath("html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[1]/div[1]/div/table/tbody/tr/td"));
    uploadButton.click();

    //From storytab double click on story named 'storytest'
    Thread.sleep(2000);
    WebElement storytest = driver.findElement(By.xpath(
            "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div/div[3]"));
    storytest.click();
    WebElement storytest1 = driver.findElement(By.xpath(
            "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div/div[3]"));

    storytest1.click();
    storytest1.click();

    Thread.sleep(3000);
    //Select the video element in timeline div[class="thumbnailStrip"]
    WebElement timelinebar = driver.findElement(By.cssSelector("div[class='thumbnailStrip']"));
    timelinebar.click();

    Thread.sleep(2000);

    WebElement timebarnumber = driver.findElement(
            By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']"));
    final String timevalue = timebarnumber.getText();

    WebElement timebarnumber1 = driver.findElement(
            By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']"));
    final String timevalue1 = timebarnumber.getText();

    Actions action = new Actions(driver);

    //Asserting if presence of element shows false after deletion button is pressed
    action.sendKeys(Keys.DELETE).build().perform();
    Boolean isPresent2 = driver.findElements(By.cssSelector("div[class='thumbnailStrip']")).size() > 0;
    Assert.assertEquals(false, isPresent2);

    // Undoing the change to timeline by pressing 'CTRL + Z'
    Thread.sleep(2000);
    Actions action2 = new Actions(driver);
    action2.keyDown(Keys.CONTROL).sendKeys(String.valueOf('\u007A')).perform();

    /*
    Thread.sleep(2000);
    Actions action = new Actions(driver);
    //String selectAll = Keys.chord(Keys.CONTROL, "a");
            
    action.sendKeys(".").perform();
    // action.sendKeys(selectAll).build().perform();
    //action.sendKeys(Keys.getKeyFromUnicode('selectAll')).build().perform();
    */

}

From source file:CakeHomePageTest.java

private void clickNavElm(String elm) {

    List<WebElement> elms = driver.findElements(By.cssSelector(".navbar-inner .nav li a"));

    for (WebElement element : elms) {
        System.out.println(element.getText());
        if (elm.equals(element.getText())) {
            element.click();/*from  www  . j a  v  a  2  s  .c  om*/
            return;
        }
    }

}