List of usage examples for org.openqa.selenium.support.ui ExpectedConditions elementToBeClickable
public static ExpectedCondition<WebElement> elementToBeClickable(final WebElement element)
From source file:org.kie.base.KIESeleniumTest.java
License:Apache License
public static void generateWait(WebDriver driver, By element) { WebDriverWait wait = new WebDriverWait(driver, 60); wait.until(ExpectedConditions.elementToBeClickable(element)); }
From source file:org.kie.base.KIESeleniumTest.java
License:Apache License
public static void generateWait(WebDriver driver, WebElement element) { WebDriverWait wait = new WebDriverWait(driver, 60); wait.until(ExpectedConditions.elementToBeClickable(element)); }
From source file:org.kie.smoke.wb.selenium.util.Waits.java
License:Apache License
public static WebElement elementClickable(WebDriver driver, By locator) { WebElement clickableElement = new WebDriverWait(driver, DEFAULT_TIMEOUT) .until(ExpectedConditions.elementToBeClickable(locator)); return clickableElement; }
From source file:org.kie.wb.selenium.util.Waits.java
License:Apache License
public static WebElement elementClickable(By locator) { WebElement clickableElement = new WebDriverWait(GrapheneUtil.getDriver(), DEFAULT_TIMEOUT) .until(ExpectedConditions.elementToBeClickable(locator)); return clickableElement; }
From source file:org.mousephenotype.cda.selenium.SearchPageTest.java
License:Apache License
@Test @Ignore// w w w . ja v a 2s. c o m public void testRandomMgiIds() throws TestException, JSONException { String testName = Thread.currentThread().getStackTrace()[1].getMethodName(); Date start = new Date(); RunStatus masterStatus = new RunStatus(); int nbRows = 20; testUtils.logTestStartup(logger, this.getClass(), testName, nbRows, nbRows); String newQueryString = "/gene/select?q=mgi_accession_id:*&fq=-marker_symbol:CGI_* AND -marker_symbol:Gm*&fl=mgi_accession_id,marker_symbol&wt=json"; Random rn = new Random(); int startIndex = rn.nextInt(40000 - 0 + 1) + 1; newQueryString += "&start=" + startIndex + "&rows=" + nbRows; JSONObject geneResults; try { geneResults = JSONRestUtil.getResults(solrUrl + newQueryString); } catch (Exception e) { throw new TestException(testName + ": Error getting gene results", e); } JSONArray docs = JSONRestUtil.getDocArray(geneResults); if (docs != null) { int size = docs.length(); int count; for (int i = 0; i < size; i++) { RunStatus status = new RunStatus(); count = i + 1; String mgiId = docs.getJSONObject(i).getString("mgi_accession_id"); String symbol = docs.getJSONObject(i).getString("marker_symbol"); String target = paBaseUrl + "/search?q=" + mgiId; String message = "[" + String.format("% 2d", i) + ": " + String.format("%-10s", mgiId) + "]. URL: " + target; driver.get(target); new WebDriverWait(driver, 25) .until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.geneCol"))); try { driver.findElement(By.cssSelector("div.geneCol a").linkText(symbol)); if (!status.hasErrors()) status.successCount++; String statusString = "\t" + (status.hasErrors() ? "FAILED " : "PASSED "); System.out.println(statusString + message); masterStatus.add(status); } catch (Exception e) { System.out.println("FAILED [ " + message + "]\n[" + e.getLocalizedMessage() + "]"); e.printStackTrace(); masterStatus.addError(message); } } } testUtils.printEpilogue(testName, start, masterStatus, nbRows, nbRows); }
From source file:org.mousephenotype.cda.selenium.support.GenePage.java
License:Apache License
/** * Waits for the gene page to load./* w w w.j ava 2 s . c om*/ */ private void load() throws TestException { try { driver.get(target); wait.until(ExpectedConditions .elementToBeClickable(By.xpath("//span[@id='summaryLinks']/following-sibling::a"))); if (isOopsPage()) { throw new TestException("GenePage: Found 'Oops...' page. URL: " + target); } wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("span#enu"))); } catch (Exception e) { throw new TestException( "GenePage: failed to load url. Reason: " + e.getLocalizedMessage() + "\nURL: " + target); } List<WebElement> elements; // Check for phenotype associations. If any, determine whether or not the page has graphs by looking for one or // more post qc links. elements = driver.findElements(By.xpath("//table[@id='genes']")); hasGenesTable = !elements.isEmpty(); if (hasGenesTable) { elements = driver.findElements(By.xpath("//*[@id='phenotypesDiv']//td[@class='postQcLink']/a")); hasGraphs = (elements.size() > 0); } // Check for expression. // Check for phenotype associated images. elements = driver.findElements(By.xpath("//*[@id='section-images']/following-sibling::div[1]//h5")); if (!elements.isEmpty()) { String text = elements.get(0).getText().toLowerCase(); hasImages = text.contains("legacy"); hasImpcImages = text.contains("associated images"); } // Check for disease models. elements = driver.findElements(By.xpath("//*[@id='predicted_diseases_table']")); if (!elements.isEmpty()) { hasDiseaseModels = !elements.isEmpty(); } }
From source file:org.mousephenotype.cda.selenium.support.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. * * @param facetId HTML 'li' id of desired facet to click * @return the [total] results count//from w ww. j av a 2 s . co m */ public int clickFacetById(String facetId) throws TestException { // Clicking the li element opens the facet but does not close it. Click on the subfacetText in the span instead. WebElement element = wait.until(ExpectedConditions .elementToBeClickable(By.xpath("//li[@id='" + facetId + "']//span[@class='flabel']"))); testUtils.scrollToTop(driver, element, -50); // Scroll element into view. element.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. setFacetTable(); } catch (Exception e) { System.out.println("SearchPage.clickFacetById: Exception: " + e.getLocalizedMessage() + "\nURL: " + driver.getCurrentUrl()); e.printStackTrace(); throw new TestException(e); } return getTabResultCountFooter(); }
From source file:org.mousephenotype.cda.selenium.support.SearchPage.java
License:Apache License
/** * Click the specified facet tab//from w ww . jav a 2 s . c o m * * @param facet the facet tab to click * * @return the facet's count */ public int clickTab(Facet facet) { WebElement element = wait .until(ExpectedConditions.elementToBeClickable(By.xpath("//li[@id='" + facet.getTabId() + "']/a"))); element.click(); // Wait until "Showing x to y of z entries" at footer. wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='dTable_info']"))); return getTabResultCountFooter(facet); }
From source file:org.mousephenotype.cda.selenium.support.SearchPage.java
License:Apache License
/** * Returns the production status order button elements (e.g. 'ES Cells', * 'Mice tm1.1', 'Mice tm1', etc.)//from w ww . j a v a 2 s . c om * * @param geneTrElement a valid gene element, derived from the selected tr * row under the geneGrid table (a tr element pointing to the desired gene * row) * * @return the production status order button elements (e.g. 'ES Cells', * 'Mice tm1.1', 'Mice tm1', etc.) */ public List<WebElement> getProductionStatusOrderButtons(WebElement geneTrElement) { List<WebElement> retVal = new ArrayList(); WebDriverWait wait = new WebDriverWait(driver, timeoutInSeconds); wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//*[@oldtitle]"))); try { List<WebElement> elements = geneTrElement.findElements(By.xpath(".//*[@oldtitle]")); for (WebElement element : elements) { if (element.getTagName().equals("a")) retVal.add(element); } } catch (Exception e) { } return retVal; }
From source file:org.mousephenotype.cda.selenium.support.SearchPage.java
License:Apache License
/** * Return the download url base based on download type * @param downloadType The download button type (e.g. page/all, tsv/xls) * @return the download url base embedded in the <i>downloadType</i> button. *//* www . j av a 2 s.com*/ private String getDownloadUrl(DownloadType downloadType) { final String xpath = "//a[@id='" + downloadType.getName() + "A']"; WebElement downloadLinkElement = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(xpath))); String attr = downloadLinkElement.getAttribute("href"); return attr; }