Example usage for org.openqa.selenium WebElement getTagName

List of usage examples for org.openqa.selenium WebElement getTagName

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement getTagName.

Prototype

String getTagName();

Source Link

Document

Get the tag name of this element.

Usage

From source file:org.jwatter.browser.WebDriverWebAutomationFramework.java

License:Apache License

protected static boolean isRadioButtonElement(WebElement element) {
    return "input".equals(element.getTagName()) && "radio".equals(element.getAttribute("type"));
}

From source file:org.jwatter.browser.WebDriverWebAutomationFramework.java

License:Apache License

protected static boolean isButtonElement(WebElement element) {
    return ("input".equals(element.getTagName()) && "submit".equals(element.getAttribute("type")))
            || "button".equals(element.getTagName());
}

From source file:org.kuali.kra.test.infrastructure.KcSeleniumHelper.java

License:Educational Community License

/**
 * Gets the value of a control field./*ww  w  .ja v a  2s . c om*/
 *
 * @param locator the id, name, title, or link name of the element to click on depending on the value of {@code exact}
 * @param exact whether the locator should match exactly
 * @return the value of the element
 */
public final String get(final String locator, final boolean exact) {
    String value = Constants.EMPTY_STRING;

    WebElement element = getElement(locator, exact);
    String tagName = element.getTagName();
    String elementType = element.getAttribute("type");

    logger.debug("Getting the value of {} from the element which has a tag of {} and a type of {}",
            new String[] { value, tagName, elementType });

    if (StringUtils.equals(tagName, "input") && StringUtils.equals(elementType, "checkbox")) {
        value = getCheckbox(element);
    } else if (StringUtils.equals(tagName, "input") && StringUtils.equals(elementType, "radio")) {
        value = getRadio(element);
    } else if (StringUtils.equals(tagName, "select")) {
        value = getSelect(element);
    } else {
        value = element.getAttribute("value");
    }

    logger.debug("Got the value of {} from the element which has a tag of {} and a type of {}",
            new String[] { value, tagName, elementType });

    return value;
}

From source file:org.kuali.kra.test.infrastructure.KcSeleniumHelper.java

License:Educational Community License

/**
 * Sets the value of a control field./*from w ww.jav a2  s .com*/
 *
 * @param locator the id, name, title, or link name of the element to set depending on the value of {@code exact}
 * @param exact whether the locator should match exactly
 * @param value the new value of the element
 */
public final void set(final String locator, final boolean exact, final String value) {
    WebElement element = getElement(locator, exact);
    String tagName = element.getTagName();
    String elementType = element.getAttribute("type");

    logger.debug("Setting the value to {} of the element which has a tag of {} and a type of {}",
            new String[] { value, tagName, elementType });

    if (StringUtils.equals(tagName, "input") && StringUtils.equals(elementType, "checkbox")) {
        setCheckbox(element, value);
    } else if (StringUtils.equals(tagName, "input") && StringUtils.equals(elementType, "file")) {
        setFile(element, value);
    } else if (StringUtils.equals(tagName, "input") && StringUtils.equals(elementType, "radio")) {
        setRadio(locator, exact, value);
    } else if (StringUtils.equals(tagName, "select")) {
        setSelect(element, value);
    } else {
        element.clear();
        element.sendKeys(value);
    }

    logger.debug("Set the value to {} of the element which has a tag of {} and a type of {}",
            new String[] { value, tagName, elementType });
}

From source file:org.mousephenotype.cda.selenium.support.Paginator.java

License:Apache License

private void dumpElement(WebElement element) {
    System.out.println("\n      id = " + element.getAttribute("id"));
    System.out.println("tag name = " + element.getTagName());
    System.out.println("   class = " + element.getAttribute("class"));
    System.out.println("    text = " + element.getText());
}

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.)/*w  ww . ja  va 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.TestUtils.java

License:Apache License

public String webElementToString(WebElement webElement) {
    String retVal = "";
    retVal += "class='" + webElement.getAttribute("class") + "'";
    retVal += ",id='" + webElement.getAttribute("id") + "'";
    retVal += ",tag name='" + webElement.getTagName() + "'";
    retVal += ",text='" + webElement.getText() + "'\n";

    return retVal;
}

From source file:org.mozilla.jmarionette.app.MarionetteDriverTest.java

License:Mozilla Public License

@Test
public void testFindElement() {
    driver.navigate().to("https://mozilla.org");
    final WebElement element = driver.findElement(By.id("home"));
    org.junit.Assert.assertNotNull(element);
    org.junit.Assert.assertEquals("body", element.getTagName());
}

From source file:org.mule.modules.selenium.SeleniumModule.java

License:Open Source License

/**
 * Get the tag name of this element. <b>Not</b> the value of the name attribute: will return
 * <code>"input"</code> for the element <code>&lt;input name="foo" /&gt;</code>.
 * <p/>// w w w. ja  va  2s . com
 * {@sample.xml ../../../doc/mule-module-selenium.xml.sample selenium:get-tag-name}
 *
 * @return The tag name of this element.
 */
public String getTagName(@Payload WebElement element) {
    return element.getTagName();
}

From source file:org.musetest.selenium.values.SelectedLabel.java

License:Open Source License

@Override
public String resolveValue(MuseExecutionContext context) throws ValueSourceResolutionError {
    WebElement element = resolveElementSource(context, true);
    Select select;/*w  w w. j a va2  s.c o  m*/
    try {
        select = new Select(element);
    } catch (UnexpectedTagNameException e) {
        throw new ValueSourceResolutionError(
                String.format("The element must be a <select> - found a %s", element.getTagName()));
    }
    String label = select.getFirstSelectedOption().getText();
    context.raiseEvent(ValueSourceResolvedEventType.create(getDescription(), label));
    return label;
}