List of usage examples for org.openqa.selenium.support.ui ExpectedConditions elementToBeClickable
public static ExpectedCondition<WebElement> elementToBeClickable(final WebElement element)
From source file:org.mousephenotype.www.SearchPageTest.java
License:Apache License
@Test //@Ignore// ww w . ja v a2s . c om public void testTickingFacetFilters() throws Exception { testCount++; System.out.println(); String testName = "testTickingFacetFilters"; System.out.println("\n\n----- " + testName + " -----"); System.out.println("TESTING clicking on a facet checkbox will add a filter to the filter summary box"); System.out.println("TESTING removing a filter on the list will uncheck a corresponding checkbox"); String message; successList.clear(); errorList.clear(); String target = baseUrl + "/search"; logger.debug("target Page URL: " + target); SearchPage searchPage = new SearchPage(driver, timeout_in_seconds, target, phenotypePipelineDAO, baseUrl); // For each core: // Click the first subfacet. // Check that it is selected. // Check that there is a filter matching the selected facet above the Genes facet. // Click the first subfacet again to unselect it. // Check that it is unselected. // Check that there is no filter matching the just-unselected facet above the Genes facet. for (String core : cores) { String subfacetCheckboxCssSelector = "li#" + core + " li.fcat input[type='checkbox']"; String subfacetTextCssSelector = "li#" + core + " li.fcat span.flabel"; int iterationErrorCount = 0; Facet facet = searchPage.getFacetByCoreName(core); searchPage.openFacet(facet); // Open facet if it is not alreay opened. WebElement firstSubfacetElement = wait .until(ExpectedConditions.elementToBeClickable(By.cssSelector(subfacetCheckboxCssSelector))); firstSubfacetElement.click(); // Select the first subfacet. searchPage.openFacet(facet); // Re-open the facet as, by design, it closed after the click() above. if (!firstSubfacetElement.isSelected()) { // Verify that the subfacet is selected. iterationErrorCount++; message = "Failed to check input filter for " + facet + " facet."; errorList.add(message); logger.error(message); } // Check that there is a filter matching the selected facet above the Genes facet. String facetText = driver.findElement(By.cssSelector(subfacetTextCssSelector)).getText(); HashMap<Facet, SearchPage.FacetFilter> facetFilterHash = searchPage.getFacetFilter(); List<String> facetFilterText = facetFilterHash.get(facet).subfacetTexts; boolean found = false; for (String facetFilter : facetFilterText) { if (facetFilter.contains(facetText)) { found = true; break; } } if (!found) { iterationErrorCount++; message = "ERROR: Couldn't find subfacet '" + facetText + "' in facet " + facet; errorList.add(message); logger.error(message); } searchPage.openFacet(facet); // Open facet if it is not alreay opened. firstSubfacetElement.click(); // Deselect the first subfacet. searchPage.openFacet(facet); // Re-open the facet as, by design, it closed after the click() above. // The page becomes stale after the click() above, so we must re-fetch the WebElement objects. firstSubfacetElement = wait .until(ExpectedConditions.elementToBeClickable(By.cssSelector(subfacetCheckboxCssSelector))); if (firstSubfacetElement.isSelected()) { // Verify that the subfacet is no longer selected. iterationErrorCount++; message = "Failed to uncheck input filter for " + facet + " facet."; errorList.add(message); logger.error(message); } // Check that there are no filters. if (searchPage.hasFilters()) { iterationErrorCount++; message = "ERROR: Expected filters to be cleared, but there were filters in place for facet " + facet; errorList.add(message); logger.error(message); } if (iterationErrorCount == 0) { logger.info(" " + core + " OK"); successList.add(core); } searchPage.clearFilters(); } System.out.println(); if (successList.size() == params.size()) { System.out.println("[PASSED] - " + testName); sumSuccessList.add("passed"); } else { System.out.println("[FAILED] - " + testName + "\n" + StringUtils.join(errorList, "\n")); sumErrorList.add("[FAILED] - " + testName + "\n" + StringUtils.join(errorList, "\n")); fail("There were " + sumErrorList.size() + " errors."); } System.out.println(); }
From source file:org.mousephenotype.www.SearchPageTest.java
License:Apache License
@Test //@Ignore//from w w w . j ava2 s . c om public void testRandomMgiIds() throws Exception { testCount++; System.out.println(); String testName = "testRandomMgiIds"; System.out.println("\n\n----- " + testName + " -----"); successList.clear(); errorList.clear(); 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; int nbRows = 20; newQueryString += "&start=" + startIndex + "&rows=" + nbRows; //System.out.println("newQueryString=" + newQueryString); System.out.println("TESTING " + nbRows + " random MGI IDs"); JSONObject geneResults = JSONRestUtil.getResults(solrUrl + newQueryString); JSONArray docs = JSONRestUtil.getDocArray(geneResults); if (docs != null) { int size = docs.size(); int count; for (int i = 0; i < size; i++) { count = i + 1; String mgiId = docs.getJSONObject(i).getString("mgi_accession_id"); String symbol = docs.getJSONObject(i).getString("marker_symbol"); System.out.print("Testing MGI ID " + String.format("%3d", count) + ": " + String.format("%-10s", mgiId) + "\t=>\t"); driver.get(baseUrl + "/search?q=" + mgiId); driver.navigate().refresh(); //new WebDriverWait(driver, 25).until(ExpectedConditions.visibilityOfElementLocated(By.id("div.geneCol"))); new WebDriverWait(driver, 25) .until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.geneCol"))); //WebElement geneLink = driver.findElement(By.xpath("//a[@href='/data/genes/" + mgiId + "'")); WebElement geneLink = null; try { geneLink = driver.findElement(By.cssSelector("div.geneCol a").linkText(symbol)); System.out.println("OK"); successList.add(mgiId); //Thread.sleep(thread_wait_in_seconds); } catch (Exception e) { System.out.println("FAILED"); errorList.add(mgiId); continue; } try { Thread.sleep(thread_wait_in_ms); } catch (Exception e) { } } System.out.println(); if (successList.size() == nbRows) { System.out.println("[PASSED] - " + testName); sumSuccessList.add("passed"); } else { System.out.println("[FAILED] - " + testName + "\n" + StringUtils.join(errorList, "\n")); sumErrorList.add("[FAILED] - " + testName + "\n" + StringUtils.join(errorList, "\n")); fail("There were " + sumErrorList.size() + " errors."); } System.out.println(); } }
From source file:org.mousephenotype.www.SearchPageTest.java
License:Apache License
private void specialStrQueryTest(String testName, String qry) throws Exception { testCount++;/* w ww. ja v a 2 s . c om*/ System.out.println("\n\n----- " + testName + " -----"); successList.clear(); errorList.clear(); driver.get(baseUrl + "/search?q=" + qry); new WebDriverWait(driver, 25).until(ExpectedConditions.elementToBeClickable(By.id("geneGrid_info"))); String foundMsg = driver.findElement(By.cssSelector("span#resultCount a")).getText(); if (foundMsg.isEmpty()) { System.out.println("[FAILED] - queried " + qry); sumErrorList.add("[FAILED] - queried " + qry); fail("There were " + sumErrorList.size() + " errors."); } else { System.out.println("[PASSED] - queried " + qry + ". Found " + foundMsg); sumSuccessList.add("passed"); } System.out.println(); }
From source file:org.mousephenotype.www.testing.model.SearchPage.java
License:Apache License
/** * Returns the state of the facet: OPEN or CLOSED. * @param facet facet to be queried//w w w . j av a 2s .c o m * @return the state of the facet: OPEN or CLOSED. */ public WindowState getFacetState(Facet facet) { String facetId = facet.getFacetId(); WebElement facetElement = wait .until(ExpectedConditions.elementToBeClickable(By.cssSelector("li#" + facetId))); return facetElement.getAttribute("class").contains("open") ? WindowState.OPEN : WindowState.CLOSED; }
From source file:org.nuxeo.functionaltests.pages.workspace.WorkspaceHomePage.java
License:Apache License
public WorkspaceRepositoryPage goToRepository() { Locator.getFluentWait().ignoring(NoSuchElementException.class) .until(ExpectedConditions.visibilityOf(breadcrumbForm)); DocumentBasePage.makeBreadcrumbUsable(driver); WebElement first = breadcrumbForm.findElements(By.className("jsBreadcrumbActionList")).get(0) .findElement(By.tagName("li")); Locator.scrollToElement(first); Locator.getFluentWait().until(ExpectedConditions.elementToBeClickable(first)); first.click();/*from w w w. j av a2 s. c o m*/ Locator.findElementWaitUntilEnabledAndClick(first, By.linkText("Repository")); return asPage(WorkspaceRepositoryPage.class); }
From source file:org.nvonop.selenium.framework.actionbot.BaseBot.java
License:Open Source License
private void waitForElementThenInitialise() { WebDriverWait wait = new WebDriverWait(driver, timeout); try {/*from w ww. j a v a2s .c o m*/ baseWebElement = wait.until(ExpectedConditions.elementToBeClickable(locator)); waitForControlToStopMoving(); } catch (InterruptedException e) { LOGGER.log(Level.INFO, "InterruptedException in findControl() method", e); } catch (TimeoutException e) { LOGGER.log(Level.INFO, "TimeoutException in findControl() method", e); } if (baseWebElement == null) { baseWebElement = driver.findElement(locator); } }
From source file:org.nvonop.selenium.framework.controls.BaseControl.java
License:Open Source License
private void waitForElementThenInitialise() { WebDriverWait wait = new WebDriverWait(driver, timeout); try {// www . j ava 2 s. c om baseWebElement = wait.until(ExpectedConditions.elementToBeClickable(getLocator())); waitForControlToStopMoving(); } catch (InterruptedException e) { LOGGER.log(Level.INFO, "InterruptedException in findControl() method", e); } catch (TimeoutException e) { LOGGER.log(Level.INFO, "TimeoutException in findControl() method", e); } if (baseWebElement == null) { baseWebElement = driver.findElement(locator); } }
From source file:org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest.java
License:Open Source License
protected void loginToSystem(UserCredentials credentials, UserRoleEnum role) throws Exception { sendUserAndPasswordKeys(credentials); refreshAttempts = (refreshAttempts == 0) ? NUM_OF_ATTEMPTS_TO_REFTRESH : refreshAttempts; if (!getRole().equals(UserRoleEnum.ADMIN)) { try {/*from w ww . j a v a 2 s . co m*/ if (!localEnv) { // GeneralUIUtils.ultimateWait(); WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 3 * 60); WebElement sdcApp = wait.until(ExpectedConditions.elementToBeClickable(By.id("app-image-SDC"))); sdcApp.click(); GeneralUIUtils.getDriver().switchTo().frame(1); GeneralUIUtils.waitFordataTestIdVisibility("main-menu-input-search"); } else { enterToUserWorkspace(); } } catch (Exception e) { refreshAttempts--; if (refreshAttempts <= 0) { System.out.println("ERR : Something is wrong with browser!"); Assert.fail("ERR : Something is wrong with browser!"); } System.out.println("trying again..."); System.out.println(String.format("%s attempt(s) left", refreshAttempts)); extendTest.log(LogStatus.INFO, "trying again..."); extendTest.log(LogStatus.INFO, String.format("%s attempt(s) left", refreshAttempts)); quitAndReLogin(role); } } }
From source file:org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest.java
License:Open Source License
public void loginToSystem(UserRoleEnum role) { WebDriver driver = GeneralUIUtils.getDriver(); WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//*[@method='" + "post" + "']")))); WebElement userIdTextbox = GeneralUIUtils.waitForElementVisibility(By.name("userId")); userIdTextbox.sendKeys(role.getUserId()); WebElement passwordTextbox = GeneralUIUtils.waitForElementVisibility(By.name("password")); passwordTextbox.sendKeys("123123a"); wait.until(ExpectedConditions .elementToBeClickable(driver.findElement(By.xpath("//*[@value='" + "Submit" + "']")))).click(); GeneralUIUtils.waitForLoader();/* w ww. j av a2 s .com*/ }
From source file:org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils.java
License:Open Source License
public static WebElement getWebButton(String dataTestId) { WebDriverWait wait = new WebDriverWait(driver, 3 * 60); return wait.until( ExpectedConditions.elementToBeClickable(By.xpath("//*[@data-tests-id='" + dataTestId + "']"))); }