List of usage examples for org.openqa.selenium WebElement getTagName
String getTagName();
From source file:org.aludratest.service.gui.web.selenium.selenium2.condition.ElementClickable.java
License:Apache License
/** Provides the evaluation logic as static public method. * @param element the element to check//from w w w .ja v a2 s.c om * @return true if the element is clickable, otherwise false */ public static boolean isClickable(WebElement element) { if (!element.isEnabled()) { return false; } String tagName = element.getTagName().toLowerCase(); if (!EDITABLE_ELEMENTS.contains(tagName)) { return false; } if ("input".equals(tagName) && "true".equals(element.getAttribute("readonly"))) { return false; } return true; }
From source file:org.aludratest.service.gui.web.selenium.selenium2.condition.ElementEditableCondition.java
License:Apache License
@Override protected WebElement applyOnElement(WebElement element) { if (super.applyOnElement(element) == null) { return null; }/* www. j av a 2 s . c o m*/ // element must be text based input if (!"input".equalsIgnoreCase(element.getTagName())) { this.message = "Element not editable (no input component)"; return null; } String tp = element.getAttribute("type"); // all of these do NOT have a textual input representation if (tp == null || tp.toLowerCase(Locale.US) .matches("button|checkbox|color|hidden|image|radio|reset|search|submit")) { this.message = "Element not editable (wrong input component type)"; return null; } String roAttr = element.getAttribute("readonly"); if (roAttr != null && ("readonly".equals(roAttr) || "true".equals(roAttr))) { this.message = "Element not editable"; return null; } return element; }
From source file:org.aludratest.service.gui.web.selenium.selenium2.condition.ElementNotEditableCondition.java
License:Apache License
@Override protected WebElement applyOnElement(WebElement element) { if (super.applyOnElement(element) == null) { // treat "not enabled" as "not editable" -> good here return element; }//from w w w . ja v a 2 s . co m // element must be text based input - if not, treat as "not editable" if (!"input".equalsIgnoreCase(element.getTagName())) { return element; } String tp = element.getAttribute("type"); // all of these do NOT have a textual input representation if (tp == null || tp.toLowerCase(Locale.US) .matches("button|checkbox|color|hidden|image|radio|reset|search|submit")) { return element; } String roAttr = element.getAttribute("readonly"); if (roAttr != null && ("readonly".equals(roAttr) || "true".equals(roAttr))) { return element; } this.message = "Element editable"; return null; }
From source file:org.aludratest.service.gui.web.selenium.selenium2.LocatorSupport.java
License:Apache License
/** Provides the parent of a given {@link WebElement}. * @param child//from www .j ava 2 s . c om * @return */ public WebElement getParent(final WebElement child) { // return no parent for body if ("body".equals(child.getTagName())) { return null; } WebElement parent = child.findElement(By.xpath("..")); return wrapElement(parent, new ElementLookup() { @Override public WebElement perform() { return child.findElement(By.xpath("..")); } }); }
From source file:org.aludratest.service.gui.web.selenium.selenium2.Selenium2Facade.java
License:Apache License
private boolean isEditable(WebElement element) { for (int i = 0; i < MAX_RETRIES_ON_STALE_ELEMENT; i++) { try {// w ww. j a va 2 s.c o m if (!element.isEnabled()) { return false; } String tagName = element.getTagName().toLowerCase(); if (!EDITABLE_ELEMENTS.contains(tagName)) { return false; } if ("input".equals(tagName)) { String readonly = element.getAttribute("readonly"); return (readonly == null || "false".equals(readonly)); } else { return true; } } catch (StaleElementReferenceException e) { // ignore this and retry in the next loop iteration } } // assert that it is gone forever. This means "not editable". return false; }
From source file:org.apache.falcon.regression.core.util.UiUtil.java
License:Apache License
private static StringBuilder elementToString(String prefix, WebElement element, Integer limitDepth) { if (limitDepth != null && limitDepth == 0) { return new StringBuilder(); }/* w w w . j a v a 2s. c o m*/ final Integer newDepth = limitDepth == null ? null : limitDepth - 1; final StringBuilder elementStr = new StringBuilder(prefix); List<String> extraInfo = new ArrayList<>(); if (StringUtils.isNotBlank(element.getAttribute("ng-repeat"))) { extraInfo.add("array"); } elementStr.append("-> ").append(element.getTagName()).append("(").append(element.getAttribute("id")) .append(")").append("(").append(element.getAttribute("class")).append(")").append(extraInfo) .append("\t").append(StringEscapeUtils.escapeJava(element.getText())); final String childPrefix = prefix + "\t"; final List<WebElement> childElements = element.findElements(By.xpath("./*")); for (WebElement oneChildElement : childElements) { StringBuilder childStr = elementToString(childPrefix, oneChildElement, newDepth); if (childStr.length() > 0) { elementStr.append("\n").append(childStr); } } return elementStr; }
From source file:org.apache.roller.selenium.AbstractRollerPage.java
License:Apache License
protected void clickById(String buttonId) { WebElement element = driver.findElement(By.id(buttonId)); element.click();//from w ww .j a v a 2 s. com System.out.println("Element " + element.getTagName() + " id:" + element.getAttribute("id") + " clicked"); }
From source file:org.apache.roller.selenium.AbstractRollerPage.java
License:Apache License
protected void clickByLinkText(String buttonText) { WebElement element = driver.findElement(By.linkText(buttonText)); element.click();/*from w ww .j a va 2 s . c om*/ System.out.println("Element " + element.getTagName() + " id:" + element.getAttribute("id") + " clicked"); }
From source file:org.asqatasun.sebuilder.interpreter.steptype.TgClickElement.java
License:Open Source License
@Override public boolean run(TestRun ctx) { // return super.run(ctx); WebElement webElement = ctx.locator("locator").find(ctx); ctx.getLog().info("Click from " + webElement.getTagName() + " " + webElement.getText()); // boolean doesClickBringToAnotherPage = doesClickBringToAnotherPage(webElement, ctx.log(), ctx.getDriver().getCurrentUrl()); webElement.click();//from ww w. ja va 2s . c om // if (doesClickBringToAnotherPage){ // ctx.log().info("Fire New Page From a Click "); // ctx.fireNewPage(); // } return true; }
From source file:org.asqatasun.tgol.test.scenario.AbstractWebDriverTestClass.java
License:Open Source License
protected String findNewUserRowIndexLocation() { WebElement we = driver.findElement(By.xpath(USER_TABLE_BODY_XPATH_LOCATION)); if (!StringUtils.equals(we.getTagName(), "tbody")) { throw new RuntimeException(); }/* w w w . j ava 2 s .com*/ return String.valueOf(we.findElements(By.tagName("tr")).size()); }