List of usage examples for org.openqa.selenium WebElement findElements
@Override List<WebElement> findElements(By by);
From source file:com.wikia.webdriver.pageobjectsfactory.componentobject.visualeditordialogs.VisualEditorAddMediaDialog.java
License:Creative Commons License
public VisualEditorPageObject previewExistingMediaByIndex(int index) { waitForDialogVisible();//from w w w. j a v a2 s. c om WebElement mediaResultsWidget = mediaDialogBody.findElement(mediaResultsWidgetBy); waitForElementVisibleByElement(mediaResultsWidget); WebElement targetMedia = mediaResultsWidget.findElements(mediaTitlesBy).get(index); targetMedia.click(); waitForDialogNotVisible(); return new VisualEditorPageObject(driver); }
From source file:com.wikia.webdriver.pageobjectsfactory.componentobject.visualeditordialogs.VisualEditorAddMediaDialog.java
License:Creative Commons License
private WebElement findMediaByTitle(String title) { WebElement mediaResultsWidget = mediaDialogBody.findElement(mediaResultsWidgetBy); waitForElementVisibleByElement(mediaResultsWidget); return getElementByValue(mediaResultsWidget.findElements(mediaTitlesBy), "title", title); }
From source file:de.betterform.conformance.WebDriverTestFunctions.java
License:BSD License
public void selectOption(final String id, String option) { WebElement webElement = webDriver.findElement(By.id(id)); WebElement webElementValue = webDriver.findElement(By.id(id + "-value")); String controlType = webElementValue.getAttribute("controlType"); if (hasHTMlClass(webElement, "xfSelect1") && "select1RadioButton".equals(controlType)) { Iterator<WebElement> select1OptionsElements = webElement.findElements(By.cssSelector(".xfSelectorItem")) .iterator();/*from ww w . ja va2 s . c om*/ while (select1OptionsElements.hasNext()) { WebElement select1Option = select1OptionsElements.next(); if (option.equals(select1Option.getText())) { select1Option.findElement(By.name(id + "-value")).click(); return; } } } else { Select select = new Select(webDriver.findElement(By.id(id + "-value"))); select.selectByVisibleText(option); try { Thread.sleep(1000); } catch (Exception e) { } } }
From source file:de.betterform.conformance.WebDriverTestFunctions.java
License:BSD License
public boolean checkSelectionOptions(String id, String[] options) { WebElement webElement = webDriver.findElement(By.id(id)); String classes = webElement.getAttribute("class"); List<String> selectOptions = new Vector<String>(); if (classes != null) { if (classes.contains("xfSelect1")) { Iterator<WebElement> select1OptionsElements = webElement .findElements(By.cssSelector(".xfSelectorItem")).iterator(); while (select1OptionsElements.hasNext()) { selectOptions.add(select1OptionsElements.next().getText()); }/*from www . j a va 2 s .co m*/ } else if (classes.contains("xfSelect")) { Select select = new Select(webDriver.findElement(By.id(id + "-value"))); Iterator<WebElement> selectOptionsElements = select.getOptions().iterator(); while (selectOptionsElements.hasNext()) { selectOptions.add(selectOptionsElements.next().getText().trim()); } } } boolean optionsPresent = true; for (int i = 0; i < options.length; i++) { optionsPresent &= selectOptions.contains(options[i].trim()); } return optionsPresent; }
From source file:de.betterform.conformance.WebDriverTestFunctions.java
License:BSD License
private boolean hasGrouplayout(WebElement group, String apperance) { boolean validLayout = true; if (WebDriverTestInterface.appearanceFull.equals(apperance)) { if (WebDriverTestInterface.spanTagName.equals(group.getTagName())) { Iterator<WebElement> children = group .findElements(By.className(WebDriverTestInterface.xfControlClass)).iterator(); while (children.hasNext()) { WebElement child = children.next(); if (child.getAttribute("widgetid") != null) { WebElement widget = child .findElement(By.id("widget_" + child.getAttribute("widgetid") + "-value")); validLayout &= "200px".equals(widget.getCssValue("left")); validLayout &= "left".equals(widget.getCssValue("text-align")); }//from ww w . j av a 2s . co m validLayout &= WebDriverTestInterface.spanTagName.equals(child.getTagName()); } return validLayout; } } else if (WebDriverTestInterface.appearanceCompact.equals(apperance) || WebDriverTestInterface.appearanceDefault.equals(apperance)) { if (WebDriverTestInterface.spanTagName.equals(group.getTagName())) { Iterator<WebElement> children = group .findElements(By.className(WebDriverTestInterface.xfControlClass)).iterator(); while (children.hasNext()) { WebElement child = children.next(); if (child.getAttribute("widgetid") != null) { WebElement widget = child .findElement(By.id("widget_" + child.getAttribute("widgetid") + "-value")); validLayout &= "start".equals(widget.getCssValue("text-align")); } validLayout &= WebDriverTestInterface.spanTagName.equals(child.getTagName()); } return validLayout; } } else if (WebDriverTestInterface.appearanceHorizontalTable.equals(apperance)) { if (WebDriverTestInterface.tableTagName.equals(group.getTagName())) { final List<WebElement> children = group .findElements(By.tagName(WebDriverTestInterface.tableRowTagName)); if (children.size() == 3) { WebElement labelRow = children.get(1); WebElement valueRow = children.get(2); final List<WebElement> labels = labelRow .findElements(By.tagName(WebDriverTestInterface.tableColTagName)); final List<WebElement> values = valueRow .findElements(By.tagName(WebDriverTestInterface.tableColTagName)); if (labels.size() == values.size()) { for (int i = 0; i < labels.size(); i++) { validLayout &= hasHTMlClass(labels.get(i), "bfHorizontalTableLabel)"); List<WebElement> htmlLabels = labels.get(i) .findElements(By.tagName(WebDriverTestInterface.labelTagName)); validLayout &= (htmlLabels.size() == 1); validLayout &= (hasHTMlClass(htmlLabels.get(0), "bfTableLabel")); //TODO: !!!! } for (int i = 0; i < labels.size(); i++) { validLayout &= hasHTMlClass(values.get(i), "bfHorizontalTableValue)"); //TODO: !!!! } } } } } return false; }
From source file:de.dentrassi.pm.testing.DeployGroupTest.java
License:Open Source License
@Test public void testCreateDeployGroup() throws Exception { final WebContext ctx = getWebContext(); final WebDriver driver = ctx.getResolved("/deploy/auth/addGroup"); final WebElement nameField = driver.findElement(By.id("name")); nameField.sendKeys("m1"); nameField.submit();// ww w.j a v a 2s. co m for (final WebElement ele : ctx.findElements(By.tagName("tr"))) { final List<WebElement> cells = ele.findElements(By.tagName("td")); if (cells.isEmpty()) { // header line continue; } final String name = cells.get(0).getText(); if (name.equals("m1")) { addKey(cells.get(1).getText()); } } }
From source file:de.iteratec.iteraplan.webtests.poc.page.tabularreport.TabularReportPage.java
License:Open Source License
public TabularReportPage selectOutputFormat(OutputFormat format) { boolean formatAvailable = false; WebElement select = driver.findElement(outputFormatLocator); List<WebElement> options = select.findElements(By.tagName("option")); for (WebElement option : options) { if (option.getText().equals(format.getGermanLabel())) { //mark format as availabe formatAvailable = true;// ww w.j a v a 2 s . co m option.click(); break; } } //check if format wasn't available if (!formatAvailable) { throw new ElementNotFoundException(outputFormatLocator.toString(), "", format.getGermanLabel()); } //safe wait for page reloading WaitUtils.wait(2000); return this; }
From source file:de.knowwe.uitest.DiaFluxUITest.java
License:Open Source License
private void assertActiveEdges(String flow, int expectedActive, int expectedSnap) { int actualActive = 0; int actualSnap = 0; for (WebElement rule : getDriver().findElements(By.cssSelector("#" + flow + " .Rule"))) { if (!rule.findElements(By.className("traceSnap")).isEmpty()) actualSnap++;/*from w ww . j av a 2s.c o m*/ if (!rule.findElements(By.className("traceActive")).isEmpty()) actualActive++; } assertEquals(expectedActive, actualActive); assertEquals(expectedSnap, actualSnap); }
From source file:de.knowwe.uitest.DiaFluxUITest.java
License:Open Source License
protected void clickTool(String markupClass, int nth, String tooltipContains) throws UnsupportedEncodingException { WebElement markup = getDriver().findElements(By.className(markupClass)).get(nth - 1); WebElement toolMenu = markup.findElement(By.className("headerMenu")); WebElement editTool = markup.findElements(By.cssSelector(".markupMenu a.markupMenuItem")).stream() .filter(element -> Strings.containsIgnoreCase(element.getAttribute("title"), tooltipContains)) .findFirst().get();/*from w ww . j av a 2 s . com*/ if (getDriver() instanceof JavascriptExecutor) { List<WebElement> stickyRows = getDriver().findElements(By.className("sticky")); JavascriptExecutor jse = (JavascriptExecutor) getDriver(); for (WebElement row : stickyRows) { jse.executeScript("arguments[0].style.display = 'none';", row); } } new Actions(getDriver()).moveToElement(toolMenu).moveToElement(editTool).click(editTool).perform(); }
From source file:de.learnlib.alex.data.entities.actions.web.ClickElementByTextAction.java
License:Apache License
@Override protected ExecuteResult execute(WebSiteConnector connector) { final WebElementLocator nodeWithVariables = new WebElementLocator(insertVariableValues(node.getSelector()), node.getType());//from www . ja va2 s . c o m final WebElement root = connector.getElement(nodeWithVariables); final String textWithVariables = insertVariableValues(text); final List<WebElement> candidates; if (tagName == null || tagName.trim().equals("")) { candidates = root.findElements(By.xpath("//text()[normalize-space() = '" + textWithVariables + "']")); } else { candidates = root.findElements(By.tagName(tagName)); } try { if (candidates.isEmpty()) { throw new NoSuchElementException("No candidate with text '" + textWithVariables + "' found."); } for (final WebElement candidate : candidates) { final boolean hasText = candidate.getText().trim().equals(textWithVariables); if (candidate.isDisplayed() && candidate.isEnabled() && hasText) { candidate.click(); LOGGER.info(LoggerMarkers.LEARNER, "Click on element '{}' with text '{}' ", tagName, text); return getSuccessOutput(); } } throw new NoSuchElementException("No clickable element found."); } catch (Exception e) { LOGGER.info(LoggerMarkers.LEARNER, "Could not click on element '{}' with text '{}' ", tagName, text, e); return getFailedOutput(); } }