List of usage examples for org.openqa.selenium.support.ui ExpectedConditions presenceOfAllElementsLocatedBy
public static ExpectedCondition<List<WebElement>> presenceOfAllElementsLocatedBy(final By locator)
From source file:org.mousephenotype.cda.selenium.support.PhenotypePage.java
License:Apache License
/** * Waits for the pheno page to load./*from w ww . j a v a 2 s .c o m*/ */ private void load() { final String NOT_AVAILABLE = "Phenotype associations to genes and alleles will be available once data has completed quality control."; driver.get(target); wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//h2[@id='gene-variants']"))); // Get results count. [NOTE: pages with no phenotype associations don't have totals] Integer i = null; List<WebElement> elements = driver.findElements(By.cssSelector("div#phenotypesDiv div.alert")); if (elements.isEmpty()) { elements = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy( By.xpath("//div[@id='phenotypesDiv']/div[@class='container span12']/p[@class='resultCount']"))); if (!elements.isEmpty()) { String totResultsString = elements.get(0).getText(); int index = totResultsString.lastIndexOf(":"); String count = totResultsString.substring(index + 1); i = commonUtils.tryParseInt(count); } } // Determine if this page has images. elements = driver.findElements(By.xpath("//*[@id='imagesSection']/div/div/div")); hasImages = !elements.isEmpty(); // Determine if this page has phenotype associations. elements = driver.findElements(By.xpath("//table[@id='phenotypes']")); hasPhenotypesTable = !elements.isEmpty(); resultsCount = (i == null ? 0 : i); hasGraphs = (resultsCount > 0); }
From source file:org.mousephenotype.cda.selenium.support.PhenotypeTable.java
License:Apache License
/** * * @return the number of rows in the "phenotypes" table. Always include 1 extra for the heading. *///from www .ja v a 2 s . co m private int computeTableRowCount() { // Wait for page. List<WebElement> elements = wait.until( ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//table[@id='phenotypes']/tbody/tr"))); return elements.size() + 1; }
From source file:org.mousephenotype.cda.selenium.support.SearchFacetTable.java
License:Apache License
/** * * @return the number of rows in the "xxGrid" table. Always include 1 * extra for the heading.//from w w w. j av a2 s . c om */ public int computeTableRowCount() { // Wait for page. List<WebElement> elements = wait .until(ExpectedConditions.presenceOfAllElementsLocatedBy(byMap.get(TableComponent.BY_TABLE_TR))); return elements.size() + 1; }
From source file:org.mousephenotype.cda.selenium.support.SearchPage.java
License:Apache License
/** * Returns the <code>WebElement</code> button matching the given buttonIndex. * @param buttonIndex 0-relative button index * @return The <code>WebElement</code> matching <code>buttonIndex</code> * @throws IndexOutOfBoundsException if <code>buttonIndex</code> lies outside * the bounds of the range of page buttons *//*from www . j a va 2 s . c o m*/ public WebElement getButton(int buttonIndex) throws IndexOutOfBoundsException { List<WebElement> ulElements = wait.until(ExpectedConditions .presenceOfAllElementsLocatedBy(By.xpath("//div[contains(@class, 'dataTables_paginate')]/ul/li"))); if (buttonIndex < ulElements.size()) { return ulElements.get(buttonIndex); } else { throw new IndexOutOfBoundsException("SearchPage.getPage(int pageIndex): pageIndex: " + buttonIndex + ". # elements: " + ulElements.size()); } }
From source file:org.mousephenotype.www.GenePageTest.java
License:Apache License
/** * Tests that a sensible page is returned for an invalid gene id. * //from w w w. ja v a 2s.c om * @throws SolrServerException */ @Test //@Ignore public void testInvalidGeneId() throws SolrServerException { DateFormat dateFormat = new SimpleDateFormat(TestUtils.DATE_FORMAT); String testName = "testInvalidGeneId"; String target = ""; int targetCount = 1; List<String> errorList = new ArrayList(); List<String> successList = new ArrayList(); List<String> exceptionList = new ArrayList(); String message; Date start = new Date(); String geneId = "junkBadGene"; final String EXPECTED_ERROR_MESSAGE = "Oops! junkBadGene is not a valid MGI gene identifier."; System.out.println(dateFormat.format(start) + ": " + testName + " started. Expecting to process " + targetCount + " of a total of 1 records."); boolean found = false; target = baseUrl + "/genes/" + geneId; System.out.println("URL: " + target); try { driver.get(target); List<WebElement> geneLinks = (new WebDriverWait(driver, timeout_in_seconds)) .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector("div.node h1"))); if (geneLinks == null) { message = "Expected error page for MP_TERM_ID " + geneId + "(" + target + ") but found none."; errorList.add(message); } for (WebElement element : geneLinks) { if (element.getText().compareTo(EXPECTED_ERROR_MESSAGE) == 0) { found = true; break; } } if (!found) { message = "Expected error 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); } message = "SUCCESS: MGI_ACCESSION_ID " + geneId + ". URL: " + target; successList.add(message); TestUtils.printEpilogue(testName, start, errorList, exceptionList, successList, targetCount, 1); }
From source file:org.mousephenotype.www.PhenotypePageTest.java
License:Apache License
/** * Tests that a sensible page is returned for an invalid phenotype id. * // w w w.ja va2s. c o m * @throws SolrServerException */ //@Ignore @Test public void testInvalidMpTermId() throws SolrServerException { String testName = "testInvalidMpTermId"; DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); String target = ""; List<String> errorList = new ArrayList(); List<String> successList = new ArrayList(); List<String> exceptionList = new ArrayList(); String message; Date start = new Date(); String phenotypeId = "junkBadPhenotype"; final String EXPECTED_ERROR_MESSAGE = "Oops! junkBadPhenotype is not a valid mammalian phenotype identifier."; System.out.println(dateFormat.format(start) + ": " + testName + " started. Expecting to process 1 of a total of 1 records."); boolean found = false; target = baseUrl + "/phenotypes/" + phenotypeId; try { driver.get(target); List<WebElement> phenotypeLinks = (new WebDriverWait(driver, timeout_in_seconds)) .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector("div.node h1"))); if (phenotypeLinks == null) { message = "Expected error page for MP_TERM_ID " + phenotypeId + "(" + target + ") but found none."; errorList.add(message); } for (WebElement div : phenotypeLinks) { if (div.getText().equals(EXPECTED_ERROR_MESSAGE)) { found = true; break; } } } catch (Exception e) { message = "Timeout: Expected error page for MP_TERM_ID " + phenotypeId + "(" + target + ") but found none."; errorList.add(message); } if (!found) { message = "Expected error page for MP_TERM_ID " + phenotypeId + "(" + target + ") but found none."; errorList.add(message); } else { message = "SUCCESS: INTERMEDIATE_MP_TERM_ID " + phenotypeId + ". URL: " + target; successList.add(message); } TestUtils.printEpilogue(testName, start, errorList, exceptionList, successList, 1, 1); }
From source file:org.mousephenotype.www.testing.model.GraphHeading.java
License:Apache License
/** * Parse the headings.//from w w w . ja va 2 s .c om */ private void parse(ChartType chartType) throws GraphTestException { // Wait for all charts to load. wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy( By.xpath("//div[@class='section']/div[@class='inner']//div[@class='highcharts-container']"))); List<WebElement> titleElements = chartElement.findElements(By.xpath("./h2[@id='section-associations']")); if (titleElements.isEmpty()) { throw new RuntimeException("GraphHeading.parse(): Wait to get chart timed out!"); } WebElement titleElement = titleElements.get(0); this.title = titleElement.getText().trim(); String rawAllele = title.replace("Allele - ", ""); List<WebElement> supElements = titleElement.findElements(By.xpath("./sup")); String sup = (supElements.isEmpty() ? "" : titleElement.findElement(By.xpath("./sup")).getText()); AlleleParser alleleParser = new AlleleParser(rawAllele, sup); Line1Parser line1Parser = new Line1Parser(); Line2Parser line2Parser = new Line2Parser(); ParameterParser parameterParser = new ParameterParser(chartType); this.alleleSymbol = alleleParser.toString(); this.geneticBackground = line1Parser.background; this.geneSymbol = alleleParser.gene; this.metadataGroup = line2Parser.metadataGroup; this.parameterName = parameterParser.getParameterName(); this.parameterStableId = parameterParser.getParameterStableId(); this.phenotypingCenter = line1Parser.phenotypingCenter; this.pipelineName = line1Parser.pipelineName; this.pipelineLinkElement = line1Parser.pipelineLinkElement; this.parameterObject = parameterParser.getParameterObject(); this.sopLinkElement = parameterParser.getSopLinkElement(); // Set the graph type from the parameterDAO. if (parameterObject != null) { observationType = impressUtils.checkType(parameterObject); } }
From source file:org.mousephenotype.www.testing.model.GraphPage.java
License:Apache License
/** * Load the page and its section and tsv/xls download data. *///from w w w .j a va 2 s . c om private void load() throws GraphTestException { String message; driver.get(graphUrl); // Wait for page to loadScalar. Sometimes the chart isn't loaded when the 'wait()' ends, so try a few times. for (int i = 0; i < 10; i++) { try { WebElement titleElement = wait.until( ExpectedConditions.presenceOfElementLocated(By.xpath("//h2[@id='section-associations']"))); if (titleElement != null) break; } catch (Exception e) { // System.out.println("Waiting " + ((i * 10) + 10) + " milliseconds."); TestUtils.sleep(10); } } // If the page has download links, populate the download data. The map // has two keys: "tsv" and "xls". Each map's data is a list of each section's data. if (hasDownloadLinks()) { Map<TestUtils.DownloadType, List<String[][]>> downloadDataSections = new HashMap(); try { downloadDataSections = getAllDownloadData(); } catch (Exception e) { message = "Exception. URL: " + graphUrl; System.out.println(message); throw new GraphTestException(message, e); } // Populate download downloadSections data. String chartXpath = "//div[@class='section']/div[@class='inner']/div[@class='chart']"; List<WebElement> chartElements = wait .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(chartXpath))); for (int i = 0; i < chartElements.size(); i++) { WebElement chartElement = chartElements.get(i); GraphSection downloadSection = new GraphSection(driver, wait, phenotypePipelineDAO, graphUrl, chartElement, chartType); List<String[][]> allTsvSectionData = downloadDataSections.get(TestUtils.DownloadType.TSV); List<String[][]> allXlsSectionData = downloadDataSections.get(TestUtils.DownloadType.XLS); downloadSection.getDownloadDataSection().put(TestUtils.DownloadType.TSV, allTsvSectionData.get(i)); downloadSection.getDownloadDataSection().put(TestUtils.DownloadType.XLS, allXlsSectionData.get(i)); downloadSections.add(downloadSection); } if (chartElements.size() != downloadSections.size()) { throw new GraphTestException("Size mismatch: Graph page size: " + chartElements.size() + ". Download size: " + downloadDataSections.size() + ". URL: " + graphUrl); } } }
From source file:org.mousephenotype.www.testing.model.GraphSection.java
License:Apache License
/** * Load the section data.// w w w . j av a 2s.com */ private void load() throws GraphTestException { try { wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy( By.xpath("//div[@class='section']/div[@class='inner']//div[@class='highcharts-container']"))); List<WebElement> elements = chartElement .findElements(By.xpath(".//table[starts-with(@id, 'catTable')]")); if (!elements.isEmpty()) { this.catTable = new GraphCatTable(elements.get(0)); } elements = chartElement.findElements(By.xpath("./table[starts-with(@id, 'continuousTable')]")); if (!elements.isEmpty()) { this.continuousTable = new GraphContinuousTable(elements.get(0)); } this.heading = new GraphHeading(wait, phenotypePipelineDAO, chartElement, graphUrl, chartType); elements = chartElement .findElements(By.xpath("./p/a/i[starts-with(@id, 'toggle_table_buttondivChart_')]")); if (!elements.isEmpty()) { moreStatisticsLink = new MoreStatisticsLink(chartElement); } elements = chartElement.findElements(By.xpath("./table[starts-with(@id, 'globalTest')]")); if (!elements.isEmpty()) { this.globalTestTable = new GraphGlobalTestTable(graphUrl, elements.get(0)); } } catch (NoSuchElementException | TimeoutException te) { System.out.println("Expected graph page url but found none. Graph URL:\n\t" + graphUrl); throw te; } catch (Exception e) { String message = "EXCEPTION processing page: " + e.getLocalizedMessage() + ". Graph URL:\n\t" + graphUrl; System.out.println(message); throw new GraphTestException(message, e); } }
From source file:org.orcid.integration.blackbox.client.SigninPage.java
License:Open Source License
public void dismissVerifyEmailModal() { List<WebElement> weList = webDriver.findElements(By.xpath("//div[@ng-controller='VerifyEmailCtrl']")); if (weList.size() > 0) {// we need to wait for the color box to appear utils.getWait().until(ExpectedConditions.presenceOfAllElementsLocatedBy( By.xpath("//div[@ng-controller='VerifyEmailCtrl' and @orcid-loading='false']"))); ((JavascriptExecutor) webDriver).executeScript("$.colorbox.close();"); utils.colorBoxIsClosed();/*from w ww. j a v a2 s . com*/ } }