List of usage examples for org.openqa.selenium.support.ui ExpectedConditions presenceOfElementLocated
public static ExpectedCondition<WebElement> presenceOfElementLocated(final By locator)
From source file:org.mousephenotype.www.testing.model.PhenotypeTable.java
License:Apache License
/** * // w ww . j av a2 s . c om * @return the number of rows in the "phenotypes" table. Always include 1 extra for the heading. */ private int computeTableRowCount() { // Wait for page. wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("//div[@id='exportIconsDiv'][@data-exporturl]"))); List<WebElement> elements = driver.findElements(By.xpath("//table[@id='phenotypes']/tbody/tr")); return elements.size() + 1; }
From source file:org.mousephenotype.www.testing.model.SearchAnatomyTable.java
License:Apache License
/** * Pulls <code>numRows</code> rows of search page gene facet data and column * access variables from the search page's 'maGrid' HTML table. * * @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./*w w w.ja v a2 s .c o m*/ * @return <code>numRows</code> rows of search page gene facet data and * column access variables from the search page's 'maGrid' HTML table. */ private GridMap load(Integer numRows) { if (numRows == null) numRows = computeTableRowCount(); String[][] pageArray; // Wait for page. wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("table#maGrid"))); 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_ANATOMY_ID] = ""; // Insure there is always a non-null value. pageArray[sourceRowIndex][COL_INDEX_ANATOMY_TERM] = ""; // Insure there is always a non-null value. for (WebElement bodyRowElements : bodyRowElementsList) { AnatomyRow anatomyRow = new AnatomyRow(); List<WebElement> bodyRowElementList = bodyRowElements.findElements(By.cssSelector("td")); WebElement element = bodyRowElementList.get(0).findElement(By.cssSelector("a")); anatomyRow.anatomyIdLink = element.getAttribute("href"); int pos = anatomyRow.anatomyIdLink.lastIndexOf("/"); anatomyRow.anatomyId = anatomyRow.anatomyIdLink.substring(pos + 1); // anatomyId. pageArray[sourceRowIndex][COL_INDEX_ANATOMY_ID] = anatomyRow.anatomyId; anatomyRow.anatomyTerm = element.getText(); // anatomyTerm. pageArray[sourceRowIndex][COL_INDEX_ANATOMY_TERM] = anatomyRow.anatomyTerm; sourceRowIndex++; bodyRows.add(anatomyRow); } } return new GridMap(pageArray, driver.getCurrentUrl()); }
From source file:org.mousephenotype.www.testing.model.SearchDiseaseTable.java
License:Apache License
/** * Pulls <code>numRows</code> rows of search page gene facet data and column * access variables from the search page's 'diseaseGrid' HTML table. * * @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.// w w w. java 2 s . co m * @return <code>numRows</code> rows of search page gene facet data and * column access variables from the search page's 'diseaseGrid' HTML table. */ private GridMap load(Integer numRows) { if (numRows == null) numRows = computeTableRowCount(); String[][] pageArray; // Wait for page. wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("table#diseaseGrid"))); 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_DISEASE_ID] = ""; // Insure there is always a non-null value. pageArray[sourceRowIndex][COL_INDEX_DISEASE_NAME] = ""; // Insure there is always a non-null value. pageArray[sourceRowIndex][COL_INDEX_SOURCE] = ""; // Insure there is always a non-null value. for (WebElement bodyRowElements : bodyRowElementsList) { // diseaseId, diseaseName, source, curatedHuman, curatedMice, candidateIMPC, candidateMGI DiseaseRow diseaseRow = new DiseaseRow(); List<WebElement> bodyRowElementList = bodyRowElements.findElements(By.cssSelector("td")); WebElement element = bodyRowElementList.get(0).findElement(By.cssSelector("a")); // Get 'Disease' element. diseaseRow.diseaseIdLink = element.getAttribute("href"); int pos = diseaseRow.diseaseIdLink.lastIndexOf("/"); diseaseRow.diseaseId = diseaseRow.diseaseIdLink.substring(pos + 1); // Add diseaseId to row element 0 from 'Disease' element. pageArray[sourceRowIndex][COL_INDEX_DISEASE_ID] = diseaseRow.diseaseId; diseaseRow.diseaseName = element.getText(); pageArray[sourceRowIndex][COL_INDEX_DISEASE_NAME] = diseaseRow.diseaseName; diseaseRow.source = bodyRowElementList.get(1).getText(); pageArray[sourceRowIndex][COL_INDEX_SOURCE] = diseaseRow.source; // Add source to row element 2 from 'Source' element. sourceRowIndex++; bodyRows.add(diseaseRow); } } return new GridMap(pageArray, driver.getCurrentUrl()); }
From source file:org.mousephenotype.www.testing.model.SearchGeneTable.java
License:Apache License
/** * Pulls <code>numRows</code> rows of search page gene facet data and column * access variables from the search page's 'geneGrid' HTML table. * * @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./*from ww w . j a va2s . c o m*/ * @return <code>numRows</code> rows of search page gene facet data and * column access variables from the search page's 'geneGrid' HTML table. */ private GridMap load(Integer numRows) { if (numRows == null) numRows = computeTableRowCount(); String[][] pageArray; // Wait for page. wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("table#geneGrid"))); 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; for (WebElement bodyRowElements : bodyRowElementsList) { GeneRow geneRow = new GeneRow(); List<WebElement> bodyRowElementList = bodyRowElements.findElements(By.cssSelector("td")); WebElement titleDivElement = bodyRowElementList.get(0) .findElement(By.cssSelector("div.geneCol div.title a")); String href = titleDivElement.getAttribute("href"); int pos = href.lastIndexOf("/"); geneRow.geneId = href.substring(pos + 1).trim(); // geneId. pageArray[sourceRowIndex][COL_INDEX_GENE_ID] = geneRow.geneId; geneRow.geneSymbol = titleDivElement.findElement(By.cssSelector("span.gSymbol")).getText().trim(); // geneSymbol. pageArray[sourceRowIndex][COL_INDEX_GENE_SYMBOL] = geneRow.geneSymbol; WebElement geneColElement = bodyRowElementList.get(0).findElement(By.cssSelector("div.geneCol")); GeneDetails geneDetails = new GeneDetails(geneColElement); geneRow.geneName = geneDetails.name; // geneName. pageArray[sourceRowIndex][COL_INDEX_GENE_NAME] = geneRow.geneName; geneRow.humanOrthologs = geneDetails.humanOrthologs; // humanOrtholog list. pageArray[sourceRowIndex][COL_INDEX_HUMAN_ORTHOLOG] = StringUtils.join(geneRow.humanOrthologs, "|"); sourceRowIndex++; bodyRows.add(geneRow); } } return new GridMap(pageArray, driver.getCurrentUrl()); }
From source file:org.mousephenotype.www.testing.model.SearchImageAnnotationView.java
License:Apache License
/** * Pulls <code>numRows</code> rows of search page gene facet data and column * access variables from the search page's 'maGrid' HTML table. * * @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./*from w ww. j a v a2s .c o m*/ * @return <code>numRows</code> rows of search page gene facet data and * column access variables from the search page's 'maGrid' HTML table. */ private GridMap load(Integer numRows) { if (numRows == null) numRows = computeTableRowCount(); String[][] pageArray; // Wait for page. wait.until(ExpectedConditions.presenceOfElementLocated(map.get(TableComponent.BY_TABLE))); 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_ANNOTATION_ID] = ""; // Insure there is always a non-null value. pageArray[sourceRowIndex][COL_INDEX_ANNOTATION_TERM] = ""; pageArray[sourceRowIndex][COL_INDEX_ANNOTATION_TYPE] = ""; pageArray[sourceRowIndex][COL_INDEX_RELATED_IMAGE_COUNT] = ""; for (WebElement bodyRowElements : bodyRowElementsList) { ImageRow bodyRow = new ImageRowFactory(bodyRowElements).getImageRow(); pageArray[sourceRowIndex][COL_INDEX_ANNOTATION_ID] = bodyRow.getAnnotationId(); pageArray[sourceRowIndex][COL_INDEX_ANNOTATION_TERM] = bodyRow.getAnnotationTerm(); pageArray[sourceRowIndex][COL_INDEX_ANNOTATION_TYPE] = bodyRow.getAnnotationType(); pageArray[sourceRowIndex][COL_INDEX_RELATED_IMAGE_COUNT] = Integer .toString(bodyRow.getRelatedImageCount()); sourceRowIndex++; bodyRows.add(bodyRow); } } return new GridMap(pageArray, driver.getCurrentUrl()); }
From source file:org.mousephenotype.www.testing.model.SearchImageImageView.java
License:Apache License
/** * Pulls <code>numRows</code> rows of search page gene facet data and column * access variables from the search page's 'maGrid' HTML table. * * @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./*from w ww.j a v a 2 s . c om*/ * @return <code>numRows</code> rows of search page gene facet data and * column access variables from the search page's 'maGrid' HTML table. */ private GridMap load(Integer numRows) { if (numRows == null) numRows = computeTableRowCount(); String[][] pageArray; // Wait for page. wait.until(ExpectedConditions.presenceOfElementLocated(map.get(TableComponent.BY_TABLE))); 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_ANNOTATION_TERMS] = ""; // Insure there is always a non-null value. pageArray[sourceRowIndex][COL_INDEX_ANNOTATION_IDS] = ""; pageArray[sourceRowIndex][COL_INDEX_ANNOTATION_ID_LINKS] = ""; pageArray[sourceRowIndex][COL_INDEX_IMAGE_LINK] = ""; for (WebElement bodyRowElements : bodyRowElementsList) { ImageRow bodyRow = new ImageRow(bodyRowElements); pageArray[sourceRowIndex][COL_INDEX_ANNOTATION_TERMS] = bodyRow.getTerms(); pageArray[sourceRowIndex][COL_INDEX_ANNOTATION_IDS] = bodyRow.getIds(); pageArray[sourceRowIndex][COL_INDEX_ANNOTATION_ID_LINKS] = bodyRow.getLinks(); pageArray[sourceRowIndex][COL_INDEX_IMAGE_LINK] = bodyRow.getImageLink(); sourceRowIndex++; bodyRows.add(bodyRow); } } return new GridMap(pageArray, driver.getCurrentUrl()); }
From source file:org.mousephenotype.www.testing.model.SearchPage.java
License:Apache License
/** * Clicks the facet and returns the result count. This has the side effect of * waiting for the page to finish loading. * /*from w w w . j a v a 2 s .c o m*/ * @param facetId HTML 'li' id of desired facet to click * @return the [total] results count */ public int clickFacetById(String facetId) { wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//li[@id='" + facetId + "']"))).click(); try { wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("//table[contains(@class, 'dataTable')]"))); // Wait for facet to load. wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("//div[contains(@class, 'dataTables_paginate')]"))); // Wait for page buttons to load. } catch (Exception e) { System.out.println("SearchPage.clickFacetById: wait timed out: " + e.getLocalizedMessage()); e.printStackTrace(); } setFacetTable(); return getResultCount(); }
From source file:org.mousephenotype.www.testing.model.SearchPage.java
License:Apache License
/** * /* ww w .j av a 2 s . c o m*/ * @param facet desired facet to click * @return the desired facet count */ public int getFacetCount(Facet facet) { WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(By .xpath("//li[@id='" + getFacetId(facet) + "']/span[@class='fcount' or @class='fcount grayout']"))); Integer niCount = Utils.tryParseInt(element.getText()); return (niCount == null ? 0 : niCount); }
From source file:org.mousephenotype.www.testing.model.SearchPage.java
License:Apache License
/** * @return The result count. This has the side effect of waiting for the * page to finish loading./*from w ww .j a v a 2s . c o m*/ */ public int getResultCount() { // Sometimes, even though we wait, the element text is still empty. Eventually it arrives (unless there are no results). WebElement element; Integer niCount = null; try { int i = 0; while ((element = wait.until(ExpectedConditions .presenceOfElementLocated(By.xpath("//div[@id='resultMsg']/span[@id='resultCount']/a")))) .getText().isEmpty()) { System.out.println("WAITING[" + i + "]"); TestUtils.sleep(500); i++; if (i > 20) return -1; } int pos = element.getText().indexOf(" "); String sCount = element.getText().substring(0, pos); niCount = Utils.tryParseInt(sCount); } catch (Exception e) { System.out.println("SearchPage.getResultCount(): There was no result count."); } return (niCount == null ? 0 : niCount); }
From source file:org.mousephenotype.www.testing.model.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 'mpGrid' HTML table. * * @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.//ww w. ja v a 2 s.c om * @return <code>numRows</code> rows of search page gene facet data and * column access variables from the search page's 'mpGrid' 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 = Utils.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, driver.getCurrentUrl()); }