Example usage for org.openqa.selenium.support.ui ExpectedConditions presenceOfElementLocated

List of usage examples for org.openqa.selenium.support.ui ExpectedConditions presenceOfElementLocated

Introduction

In this page you can find the example usage for org.openqa.selenium.support.ui ExpectedConditions presenceOfElementLocated.

Prototype

public static ExpectedCondition<WebElement> presenceOfElementLocated(final By locator) 

Source Link

Document

An expectation for checking that an element is present on the DOM of a page.

Usage

From source file:org.mousephenotype.cda.selenium.support.SearchPage.java

License:Apache License

/**
 * Returns the selected tab <code>WebElement</code>
 *
 * @return the selected tab <code>WebElement</code>
 *//*from w  w  w. j a v a  2 s  .  co m*/
public WebElement getSelectedTabElement() {
    String xpathTabName = "//div[@id='tabs']//li[@class='currDataType']";

    return wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(xpathTabName)));
}

From source file:org.mousephenotype.cda.selenium.support.SearchPhenotypeTable.java

License:Apache License

/**
 * Pulls <code>numRows</code> rows of search page gene facet data and column access variables from the search page's
 * phenotype HTML table./*from   w ww . jav a 2  s  .c om*/
 *
 * @param numRows the number of <code>GridMap</code> table rows to return, including the heading row. To specify all
 *                rows, set <code>numRows</code> to null.
 *
 * @return <code>numRows</code> rows of search page gene facet data and column access variables from the search
 * page's phenotype HTML table.
 */
private GridMap load(Integer numRows) {
    if (numRows == null)
        numRows = computeTableRowCount();

    String[][] pageArray;

    // Wait for page.
    wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("table#mpGrid")));
    int numCols = COL_INDEX_LAST + 1;

    pageArray = new String[numRows][numCols]; // Allocate space for the data.
    for (int i = 0; i < numCols; i++) {
        pageArray[0][i] = "Column_" + i; // Set the headings.
    }

    // Save the body values.
    List<WebElement> bodyRowElementsList = table.findElements(By.cssSelector("tbody tr"));
    if (!bodyRowElementsList.isEmpty()) {
        int sourceRowIndex = 1;

        pageArray[sourceRowIndex][COL_INDEX_COMP_MAPPED_HP_TERMS] = "";
        pageArray[sourceRowIndex][COL_INDEX_DEFINITION] = "";
        pageArray[sourceRowIndex][COL_INDEX_PHENOTYPE_ID] = "";
        pageArray[sourceRowIndex][COL_INDEX_PHENOTYPE_TERM] = "";
        pageArray[sourceRowIndex][COL_INDEX_PHENOTYPE_ID_LINK] = "";
        pageArray[sourceRowIndex][COL_INDEX_SYNONYMS] = "";
        pageArray[sourceRowIndex][COL_INDEX_PHENOTYPING_CALLS] = "";

        for (WebElement bodyRowElements : bodyRowElementsList) {
            PhenotypeRow phenotypeRow = new PhenotypeRow();
            List<WebElement> bodyRowElementList = bodyRowElements.findElements(By.cssSelector("td"));
            // Sometimes there is only an anchor element (and no mpCol) inside the td.....
            List<WebElement> titleDivElements = bodyRowElementList.get(0)
                    .findElements(By.cssSelector("div.mpCol div.title a"));
            WebElement titleDivElement = (titleDivElements.isEmpty()
                    ? bodyRowElementList.get(0).findElement(By.cssSelector("a"))
                    : titleDivElements.get(0));
            phenotypeRow.phenotypeIdLink = titleDivElement.getAttribute("href"); // phenotypeIdLink.
            pageArray[sourceRowIndex][COL_INDEX_PHENOTYPE_ID_LINK] = phenotypeRow.phenotypeIdLink;

            int pos = phenotypeRow.phenotypeIdLink.lastIndexOf("/");
            phenotypeRow.phenotypeId = phenotypeRow.phenotypeIdLink.substring(pos + 1).trim(); // phenotypeId.
            pageArray[sourceRowIndex][COL_INDEX_PHENOTYPE_ID] = phenotypeRow.phenotypeId;

            phenotypeRow.phenotypeTerm = titleDivElement.getText().trim(); // phenotypeTerm.
            pageArray[sourceRowIndex][COL_INDEX_PHENOTYPE_TERM] = phenotypeRow.phenotypeTerm;

            List<WebElement> mpColElements = bodyRowElementList.get(0)
                    .findElements(By.cssSelector("div.mpCol"));
            if (!mpColElements.isEmpty()) {
                PhenotypeDetails phenotypeDetails = new PhenotypeDetails(mpColElements.get(0));
                phenotypeRow.synonyms = phenotypeDetails.synonyms; // synonym list.
                pageArray[sourceRowIndex][COL_INDEX_SYNONYMS] = phenotypeRow.toStringSynonyms();

                phenotypeRow.hpTerms = phenotypeDetails.hpTerms; // hp terms.
                pageArray[sourceRowIndex][COL_INDEX_COMP_MAPPED_HP_TERMS] = phenotypeRow.toStringHpTerms();
            }
            phenotypeRow.definition = bodyRowElementList.get(1).getText(); // definition.
            pageArray[sourceRowIndex][COL_INDEX_DEFINITION] = phenotypeRow.definition;

            Integer iCalls = commonUtils.tryParseInt(bodyRowElementList.get(2).getText());
            phenotypeRow.phenotypeCalls = (iCalls == null ? 0 : iCalls);
            pageArray[sourceRowIndex][COL_INDEX_PHENOTYPING_CALLS] = Integer
                    .toString(phenotypeRow.phenotypeCalls);

            sourceRowIndex++;
            bodyRows.add(phenotypeRow);
        }
    }

    return new GridMap(pageArray, target);
}

From source file:org.mousephenotype.www.GenePageTest.java

License:Apache License

/**
 * Finds all MGI_ACCESSION_IDs in the genotype-phenotype
 * core that do not start with 'MGI'./*from   w  w w  .  ja va 2  s. c om*/
 * 
 * <p><em>Limit the number of test iterations by adding an entry to
 * testIterations.properties with this test's name as the lvalue and the
 * number of iterations as the rvalue. -1 means run all iterations.</em></p>
 * 
 * @throws SolrServerException 
 */
@Test
//@Ignore
public void testForBadGeneIds() throws SolrServerException {
    String testName = "testForBadGeneIds";
    DateFormat dateFormat = new SimpleDateFormat(TestUtils.DATE_FORMAT);
    List<String> geneIds = new ArrayList(geneService.getAllNonConformingGenes());
    String target = "";
    List<String> errorList = new ArrayList();
    List<String> successList = new ArrayList();
    List<String> exceptionList = new ArrayList();
    String message;
    Date start = new Date();

    int targetCount = testUtils.getTargetCount(testName, geneIds, 10);
    System.out.println(dateFormat.format(start) + ": " + testName + " started. Expecting to process "
            + targetCount + " of a total of " + geneIds.size() + " records.");

    // Loop through all non-conforming genes, testing each one for valid page load (they will likely fail).
    int i = 0;
    WebDriverWait wait = new WebDriverWait(driver, timeout_in_seconds);
    for (String geneId : geneIds) {
        if (i >= targetCount) {
            break;
        }
        i++;

        target = baseUrl + "/genes/" + geneId;
        logger.debug("gene[" + i + "] URL: " + target);

        try {
            driver.get(target);
            wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("span#enu")));
        } catch (NoSuchElementException | TimeoutException te) {
            // 25-Mar-2015 (mrelac) These CGI genes are now back in the game.
            //                message = "Expected page for MGI_ACCESSION_ID " + geneId + "(" + target + ") but found none.";
            //                errorList.add(message);
        } catch (Exception e) {
            message = "EXCEPTION processing target URL " + target + ": " + e.getLocalizedMessage();
            exceptionList.add(message);
            continue;
        }

        message = "SUCCESS: MGI_ACCESSION_ID " + geneId + ". URL: " + target;
        successList.add(message);
        TestUtils.sleep(thread_wait_in_ms);
    }

    TestUtils.printEpilogue(testName, start, errorList, exceptionList, successList, targetCount,
            geneIds.size());
}

From source file:org.mousephenotype.www.GenePageTest.java

License:Apache License

private void geneIdsTestEngine(String testName, List<String> geneIds) throws SolrServerException {
    DateFormat dateFormat = new SimpleDateFormat(TestUtils.DATE_FORMAT);

    String target = "";
    List<String> errorList = new ArrayList();
    List<String> successList = new ArrayList();
    List<String> exceptionList = new ArrayList();
    String message;//from ww w  .  j  ava 2 s.co m
    Date start = new Date();

    int targetCount = testUtils.getTargetCount(testName, geneIds, 10);
    System.out.println(dateFormat.format(start) + ": " + testName + " started. Expecting to process "
            + targetCount + " of a total of " + geneIds.size() + " records.");

    // Loop through all genes, testing each one for valid page load.
    int i = 0;
    WebDriverWait wait = new WebDriverWait(driver, timeout_in_seconds);
    for (String geneId : geneIds) {
        if (i >= targetCount) {
            break;
        }
        i++;

        //if (i == 1) geneId = "MGI:104874";
        //if (i == 2) geneId = "MGI:1096574";
        //if (i == 3) geneId = "MGI:1352464";
        target = baseUrl + "/genes/" + geneId;
        logger.debug("gene[" + i + "] URL: " + target);

        try {
            driver.get(target);
            wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("span#enu")));
            GenePage genePage = new GenePage(driver, wait, target, geneId, phenotypePipelineDAO, baseUrl);
            boolean phenotypesTableRequired = false;
            genePage.validate(phenotypesTableRequired);
        } catch (NoSuchElementException | TimeoutException te) {
            message = "Expected page for MGI_ACCESSION_ID " + geneId + "(" + target + ") but found none.";
            errorList.add(message);
            TestUtils.sleep(thread_wait_in_ms);
            continue;
        } catch (Exception e) {
            message = "EXCEPTION processing target URL " + target + ": " + e.getLocalizedMessage();
            exceptionList.add(message);
            TestUtils.sleep(thread_wait_in_ms);
            continue;
        }

        message = "SUCCESS: MGI_ACCESSION_ID " + geneId + ". URL: " + target;
        successList.add(message);

        TestUtils.sleep(thread_wait_in_ms);
    }

    TestUtils.printEpilogue(testName, start, errorList, exceptionList, successList, targetCount,
            geneIds.size());
}

From source file:org.mousephenotype.www.GenePageTest.java

License:Apache License

private void tick(String phenoStatus, String prodCentre, String phenoCentre) {
    // If no parameters were specified, set target to the default search page.
    String target = baseUrl + "/search";
    String fields = "";
    if (!((phenoStatus == null) && (prodCentre == null) && (phenoCentre == null))) {
        target += "#fq=";
        if (phenoStatus != null) {
            switch (phenoStatus) {
            case "Complete":
                fields += "(latest_phenotype_status:\"Phenotyping Complete\")";
                break;

            case "Started":
                fields += "(latest_phenotype_status:\"Phenotyping Started\")";
                break;

            case "Attempt Registered":
                fields += "(latest_phenotype_status:\"Phenotype Attempt Registered\")";
                break;

            default:
                throw new RuntimeException("tick(): unknown phenotyping status '" + phenoStatus + "'.");
            }/*from w w w .  ja v  a 2  s.  c o  m*/
        }

        if (prodCentre != null) {
            if (!fields.isEmpty()) {
                fields += " AND ";
                fields += "(latest_production_centre:\"" + prodCentre + "\")";
            }
        }

        if (phenoCentre != null) {
            if (!fields.isEmpty()) {
                fields += " AND ";
                fields += "(latest_phenotyping_centre:\"" + phenoCentre + "\")";
            }
        }

        target += fields + "&facet=gene";
    }

    driver.get(target);

    WebDriverWait wait = new WebDriverWait(driver, timeout_in_seconds);
    String xpathSelector = "//span[@id=\"resultCount\"]/a";
    wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(xpathSelector)));
}

From source file:org.mousephenotype.www.ImpcImagesTest.java

License:Apache License

private void geneIdsTestEngine(String testName, List<String> geneIds) throws SolrServerException {
    DateFormat dateFormat = new SimpleDateFormat(TestUtils.DATE_FORMAT);

    String target = "";
    List<String> errorList = new ArrayList();
    List<String> successList = new ArrayList();
    List<String> exceptionList = new ArrayList();
    String message;/* w ww  .  j ava2 s.  c  o m*/
    Date start = new Date();

    System.out.println(dateFormat.format(start) + ": " + testName + " started. Expecting to process "
            + geneIds.size() + " of a total of " + geneIds.size() + " records.");

    // Loop through all genes, testing each one for valid page load.
    int i = 0;
    WebDriverWait wait = new WebDriverWait(driver, timeout_in_seconds);
    for (String geneId : geneIds) {

        target = baseUrl + "/genes/" + geneId;
        logger.debug("gene[" + i + "] URL: " + target);

        try {
            driver.get(target);
            wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("span#enu")));
            GenePage genePage = new GenePage(driver, wait, target, geneId, phenotypePipelineDAO, baseUrl);
            boolean hasImpcImages = genePage.hasImpcImages();
            if (!hasImpcImages) {
                String localMessage = "no impc images for gene " + geneId;

                errorList.add(localMessage);
            }
            assertTrue(hasImpcImages);
            List<String> parameters = genePage.getAssociatedImpcImageSections();
            assertTrue(parameters.size() > 0);
        } catch (NoSuchElementException | TimeoutException te) {
            message = "Expected page for MGI_ACCESSION_ID " + geneId + "(" + target + ") but found none.";
            errorList.add(message);
            TestUtils.sleep(thread_wait_in_ms);
            continue;
        } catch (Exception e) {
            message = "EXCEPTION processing target URL " + target + ": " + e.getLocalizedMessage();
            exceptionList.add(message);
            TestUtils.sleep(thread_wait_in_ms);
            continue;
        }

        message = "SUCCESS: MGI_ACCESSION_ID " + geneId + ". URL: " + target;
        successList.add(message);

        TestUtils.sleep(thread_wait_in_ms);
        i++;
    }

    TestUtils.printEpilogue(testName, start, errorList, exceptionList, successList, i, geneIds.size());
}

From source file:org.mousephenotype.www.PhenotypePageStatistics.java

License:Apache License

/**
 * Walks the phenotype core collecting the count of: [phenotype] table only,
 * image(s) only, both, and none.// ww  w  .ja v a  2  s.c  om
 * 
 * @throws SolrServerException 
 */
@Test
public void testCollectTableAndImageStatistics() throws SolrServerException {
    String testName = "testCollectTableAndImageStatistics";
    DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
    List<String> phenotypeIds = new ArrayList(mpService.getAllPhenotypes());
    String target = "";
    List<String> errorList = new ArrayList();
    List<String> successList = new ArrayList();
    List<String> exceptionList = new ArrayList();

    List<String> phenotypeTableOnly = new ArrayList();
    List<String> imagesOnly = new ArrayList();
    List<String> both = new ArrayList();
    String message;
    Date start = new Date();
    Date stop;

    int pagesWithPhenotypeTableCount = 0;
    int pagesWithImageCount = 0;
    int pagesWithBoth = 0;
    List<String> urlsWithNeitherPhenotypeTableNorImage = new ArrayList();

    int targetCount = testUtils.getTargetCount(testName, phenotypeIds, 10);
    System.out.println(dateFormat.format(start) + ": " + testName + " started. Expecting to process "
            + targetCount + " of a total of " + phenotypeIds.size() + " records.");

    // Loop through first targetCount phenotype MGI links, testing each one for valid page load.
    int i = 0;
    for (String phenotypeId : phenotypeIds) {
        if (i >= targetCount) {
            break;
        }
        i++;

        boolean found = false;
        //if (i == 1) phenotypeId = "MP:0001304";

        target = baseUrl + "/phenotypes/" + phenotypeId;
        logger.debug("phenotype[" + i + "] URL: " + target);

        try {
            driver.get(target);
            (new WebDriverWait(driver, timeout_in_seconds))
                    .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("h1#top")));
            found = true;
        } catch (NoSuchElementException | TimeoutException te) {
            message = "Expected page for MP_TERM_ID " + phenotypeId + "(" + target + ") but found none.";
            errorList.add(message);
            continue;
        }
        try {
            boolean hasPhenotypeTable = false;
            boolean hasImage = false;

            // Are there any phenotype associations?
            List<WebElement> elementList = driver.findElements(By.cssSelector("div.alert"));

            hasPhenotypeTable = !TestUtils.contains(elementList, NO_PHENOTYPE_ASSOCIATIONS);

            // Are there any images?
            elementList = driver.findElements(By.cssSelector("h2#section"));
            if (TestUtils.contains(elementList, "Images")) {
                List<WebElement> imagesAccordion = driver
                        .findElements(By.cssSelector("div.accordion-body ul li"));
                if (imagesAccordion.isEmpty()) {
                    message = "ERROR: Found Image tag but there were no image links";
                    errorList.add(message);
                } else {
                    hasImage = true;
                }
            }

            if (hasPhenotypeTable && hasImage) {
                pagesWithBoth++;
                both.add(driver.getCurrentUrl());
            } else if (hasPhenotypeTable) {
                pagesWithPhenotypeTableCount++;
                phenotypeTableOnly.add(driver.getCurrentUrl());
            } else if (hasImage) {
                pagesWithImageCount++;
                imagesOnly.add(driver.getCurrentUrl());
            } else {
                urlsWithNeitherPhenotypeTableNorImage.add(driver.getCurrentUrl());
            }
        } catch (Exception e) {
            message = "EXCEPTION processing target URL " + target + ": " + e.getLocalizedMessage();
            exceptionList.add(message);
        }

        if (!found) {
            message = "h1 with id 'top' not found.";
            errorList.add(message);
        } else {
            message = "SUCCESS: MGI link OK for " + phenotypeId + ". Target URL: " + target;
            successList.add(message);
        }

        TestUtils.sleep(thread_wait_in_ms);
    }

    System.out.println("\nPhenotype pages with tables but no images: " + pagesWithPhenotypeTableCount);
    for (String s : phenotypeTableOnly) {
        System.out.println(s);
    }
    System.out.println();
    System.out.println("Phenotype pages with images but no tables: " + pagesWithImageCount);
    for (String s : imagesOnly) {
        System.out.println(s);
    }
    System.out.println();
    System.out.println("Phenotype pages with both tables and images: " + pagesWithBoth);
    for (String s : both) {
        System.out.println(s);
    }
    System.out.println();

    if (!urlsWithNeitherPhenotypeTableNorImage.isEmpty()) {
        System.out.println("WARNING: The following " + urlsWithNeitherPhenotypeTableNorImage.size()
                + " results had neither phenotype table nor images:");
        System.out.println("WARNING: Phenotype pages with neither phenotype table nor images: "
                + urlsWithNeitherPhenotypeTableNorImage.size());
        for (String s : urlsWithNeitherPhenotypeTableNorImage) {
            System.out.println("\t" + s);
        }
    }

    TestUtils.printEpilogue(testName, start, errorList, exceptionList, successList, targetCount,
            phenotypeIds.size());
}

From source file:org.mousephenotype.www.PhenotypePageTest.java

License:Apache License

/**
 * Checks the MGI links for the first MAX_MGI_LINK_CHECK_COUNT phenotype ids
 * Fetches all gene IDs (MARKER_ACCESSION_ID) with phenotype associations
 * from the genotype-phenotype core and tests to make sure there is an MGI
 * link for each./* w  ww  .jav  a2  s  .co m*/
 * 
 * <p><em>Limit the number of test iterations by adding an entry to
 * testIterations.properties with this test's name as the lvalue and the
 * number of iterations as the rvalue. -1 means run all iterations.</em></p>
 * 
 * @throws SolrServerException 
 */
@Test
//@Ignore
public void testMGI_MPLinksAreValid() throws SolrServerException {
    String testName = "testMGI_MPLinksAreValid";
    DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
    List<String> phenotypeIds = new ArrayList(genotypePhenotypeService.getAllPhenotypesWithGeneAssociations());
    String target = "";
    List<String> errorList = new ArrayList();
    List<String> successList = new ArrayList();
    List<String> exceptionList = new ArrayList();
    String message;
    Date start = new Date();

    int targetCount = testUtils.getTargetCount(testName, phenotypeIds, 10);
    System.out.println(dateFormat.format(start) + ": " + testName + " started. Expecting to process "
            + targetCount + " of a total of " + phenotypeIds.size() + " records.");

    // Loop through first targetCount phenotype MGI links, testing each one for valid page load.
    int i = 0;
    for (String phenotypeId : phenotypeIds) {
        if (i >= targetCount) {
            break;
        }

        // This one has historically been known to fail, so it is included here for testing. Failure indicates a data problem on the Mark Griffiths end.
        if (i == 0)
            phenotypeId = "MP:0013020";
        else if (i == 1)
            phenotypeId = "MP:0013017";

        i++;

        WebElement phenotypeLink;
        boolean found = false;

        target = baseUrl + "/phenotypes/" + phenotypeId;
        logger.debug("phenotype[" + i + "] URL: " + target);

        try {
            driver.get(target);
            phenotypeLink = (new WebDriverWait(driver, timeout_in_seconds)).until(ExpectedConditions
                    .presenceOfElementLocated(By.cssSelector("div.inner a").linkText(phenotypeId)));
        } catch (NoSuchElementException | TimeoutException te) {
            message = "Expected page for MP_TERM_ID " + phenotypeId + "(" + target + ") but found none.";
            errorList.add(message);
            TestUtils.sleep(thread_wait_in_ms);
            continue;
        }
        try {
            phenotypeLink.click();
            String idString = "[" + phenotypeId + "]";
            List<WebElement> elements = driver.findElements(By.cssSelector("div[id='templateBodyInsert']"));
            if (elements.isEmpty()) {
                message = "Expected valid MGI page for " + phenotypeId + "(" + target + ").";
                logger.error(message);
                errorList.add(message);
            } else {
                found = elements.get(0).getText().contains(idString);
            }
        } catch (Exception e) {
            message = "EXCEPTION processing target URL " + target + ": " + e.getLocalizedMessage();
            exceptionList.add(message);
        }

        if (!found) {
            message = "div id 'templateBodyInsert' not found.";
            errorList.add(message);
        } else {
            message = "SUCCESS: MGI link OK for " + phenotypeId + ". URL: " + target;
            successList.add(message);
        }

        TestUtils.sleep(thread_wait_in_ms);
    }

    TestUtils.printEpilogue(testName, start, errorList, exceptionList, successList, targetCount,
            phenotypeIds.size());
}

From source file:org.mousephenotype.www.PhenotypePageTest.java

License:Apache License

private void phenotypeIdsTestEngine(String testName, List<String> phenotypeIds) throws SolrServerException {
    DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
    String target;/*from   ww w.  ja  va2 s  .co m*/
    List<String> errorList = new ArrayList();
    List<String> successList = new ArrayList();
    List<String> exceptionList = new ArrayList();
    Date start = new Date();
    WebDriverWait wait = new WebDriverWait(driver, timeout_in_seconds);

    int targetCount = testUtils.getTargetCount(testName, phenotypeIds, 10);
    System.out.println(dateFormat.format(start) + ": " + testName + " started. Expecting to process "
            + targetCount + " of a total of " + phenotypeIds.size() + " records.");

    // Loop through all phenotypes, testing each one for valid page load.
    int i = 0;
    for (String phenotypeId : phenotypeIds) {
        int errorCount = 0;
        if (i >= targetCount) {
            break;
        }

        WebElement mpLinkElement = null;
        target = baseUrl + "/phenotypes/" + phenotypeId;
        System.out.println("phenotype[" + i + "] URL: " + target);

        try {
            PhenotypePage phenotypePage = new PhenotypePage(driver, wait, target, phenotypeId,
                    phenotypePipelineDAO, baseUrl);
            if (phenotypePage.hasPhenotypesTable()) {
                phenotypePage.selectPhenotypesLength(100);
                mpLinkElement = wait.until(ExpectedConditions
                        .presenceOfElementLocated(By.cssSelector("div.inner a").linkText(phenotypeId)));
                PageStatus status = phenotypePage.validate();
                if (status.hasErrors()) {
                    System.out.println(status.toStringErrorMessages());
                    errorCount++;
                }
            } else {
                // Genes that are Phenotype Started but not yet Complete have a placeholder and note that they will be available soon.
                // Thus, it is not an error if the PhenotypesTable doesn't exist.
                System.out.println("\tNo PhenotypesTable. Skipping this page ...");
                continue;
            }
        } catch (Exception e) {
            System.out.println("EXCEPTION processing target URL " + target + ": " + e.getLocalizedMessage());
            errorCount++;
        }

        if (mpLinkElement == null) {
            System.out.println(
                    "Expected page for MP_TERM_ID " + phenotypeId + "(" + target + ") but found none.");
            errorCount++;
        }

        if (errorCount > 0) {
            errorList.add("FAIL: MP_TERM_ID " + phenotypeId + ". URL: " + target);
        } else {
            successList.add("SUCCESS: MP_TERM_ID " + phenotypeId + ". URL: " + target);
        }

        i++;
        TestUtils.sleep(100);
    }

    TestUtils.printEpilogue(testName, start, errorList, exceptionList, successList, targetCount,
            phenotypeIds.size());
}

From source file:org.mousephenotype.www.SearchPageTest.java

License:Apache License

/**
 * Test for Jira bug MPII-806: from the search page, searching for the characters
 * "fasting glu" should autosuggest 'fasting glucose'. Click on 'fasting glucose'
 * and verify that the correct phenotype page appears.
 * @throws Exception //from   w  ww.  j a  v  a  2s  . co  m
 */
@Test
//@Ignore
public void testMPII_806() throws Exception {
    Date start = new Date();
    successList.clear();
    errorList.clear();
    testCount++;
    System.out.println();
    String testName = "testMPII_806";

    System.out.println("\n\n----- " + testName + " -----");

    String queryStr = baseUrl + "/search";
    driver.get(queryStr);
    driver.navigate().refresh();
    String characters = "fasting glu";
    driver.findElement(By.cssSelector("input#s")).sendKeys(characters);

    // Wait for dropdown list to appear with 'blood glucose'.
    String xpathSelector = "//ul[@id='ui-id-1']/li[@class='ui-menu-item']/a";
    WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(xpathSelector)));
    if (!element.getText().contains("fasting glucose")) {
        errorList.add("ERROR: Expected 'fasting glucose' but found '" + element.getText() + "'");
    } else {
        element.click();
        element = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@id='resultMsg']")));
        if (element.getText().contains("Found") == false) {
            errorList.add("ERROR: Expected 'Found xxx genes' message. Text = '" + element.getText() + "'");
        }
    }

    if ((errorList.isEmpty() && (exceptionList.isEmpty())))
        successList.add((testName + ": OK"));

    TestUtils.printEpilogue(testName, start, errorList, exceptionList, successList, 1, 1);
}