Codota Logo
WebElement.getTagName
Code IndexAdd Codota to your IDE (free)

How to use
getTagName
method
in
org.openqa.selenium.WebElement

Best Java code snippets using org.openqa.selenium.WebElement.getTagName (Showing top 20 results out of 774)

  • Common ways to obtain WebElement
private void myMethod () {
WebElement w =
  • Codota IconWebDriver driver;By by;driver.findElement(by)
  • Codota IconWebDriver driver;String id;driver.findElement(By.id(id))
  • Codota IconWebDriver driver;driver.findElement(By.tagName("body"))
  • Smart code suggestions by Codota
}
origin: selenide/selenide

private Describe(Driver driver, WebElement element) {
 this.driver = driver;
 this.element = element;
 sb.append('<').append(element.getTagName());
}
origin: selenide/selenide

private String serialize() {
 String text = element.getText();
 sb.append('>').append(text == null ? "" : text).append("</").append(element.getTagName()).append('>');
 return sb.toString();
}
origin: selenide/selenide

protected File uploadFile(Driver driver, WebElement inputField, File file) throws IOException {
 if (!"input".equalsIgnoreCase(inputField.getTagName())) {
  throw new IllegalArgumentException("Cannot upload file because " + Describe.describe(driver, inputField) + " is not an INPUT");
 }
 if (!file.exists()) {
  throw new IllegalArgumentException("File not found: " + file.getAbsolutePath());
 }
 String canonicalPath = file.getCanonicalPath();
 inputField.sendKeys(canonicalPath);
 return new File(canonicalPath);
}
origin: galenframework/galen

@Override
public String getText() {
  WebElement webElement = getWebElement();
  if ("input".equals(webElement.getTagName().toLowerCase())) {
    String value = webElement.getAttribute("value");
    if (value == null) {
      value = "";
    }
    
    return value;
  }
  else return getWebElement().getText().trim();
}
origin: selenide/selenide

@Override
public boolean apply(Driver driver, WebElement element) {
 String elementText = "select".equalsIgnoreCase(element.getTagName()) ?
   getSelectedOptionsTexts(element) :
   element.getText();
 return Html.text.contains(elementText, this.text.toLowerCase());
}
origin: selenide/selenide

 @Override
 public String execute(SelenideElement proxy, WebElementSource locator, Object[] args) {
  WebElement element = locator.getWebElement();
  return "select".equalsIgnoreCase(element.getTagName()) ?
    getSelectedText.execute(proxy, locator, args) :
    element.getText();
 }
}
origin: selenide/selenide

 @Override
 public Boolean execute(SelenideElement proxy, WebElementSource locator, Object[] args) {
  WebElement img = locator.getWebElement();
  if (!"img".equalsIgnoreCase(img.getTagName())) {
   throw new IllegalArgumentException("Method isImage() is only applicable for img elements");
  }
  return locator.driver().executeJavaScript("return arguments[0].complete && " +
    "typeof arguments[0].naturalWidth != 'undefined' && " +
    "arguments[0].naturalWidth > 0", img);
 }
}
origin: selenide/selenide

@Override
public WebElement execute(SelenideElement proxy, WebElementSource locator, Object[] args) {
 String text = (String) args[0];
 WebElement element = locator.findAndAssertElementIsInteractable();
 if (locator.driver().config().versatileSetValue()
  && "select".equalsIgnoreCase(element.getTagName())) {
  selectOptionByValue.execute(proxy, locator, args);
  return proxy;
 }
 if (locator.driver().config().versatileSetValue()
  && "input".equalsIgnoreCase(element.getTagName()) && "radio".equals(element.getAttribute("type"))) {
  selectRadio.execute(proxy, locator, args);
  return proxy;
 }
 setValueForTextInput(locator.driver(), element, text);
 return proxy;
}
origin: selenide/selenide

 @Override
 public WebElement execute(SelenideElement proxy, WebElementSource locator, Object[] args) {
  boolean selected = (Boolean) args[0];
  WebElement element = locator.getWebElement();
  if (!element.isDisplayed()) {
   throw new InvalidStateException(locator.driver(), "Cannot change invisible element");
  }
  String tag = element.getTagName();
  if (!tag.equals("option")) {
   if (tag.equals("input")) {
    String type = element.getAttribute("type");
    if (!type.equals("checkbox") && !type.equals("radio")) {
     throw new InvalidStateException(locator.driver(), "Only use setSelected on checkbox/option/radio");
    }
   }
   else {
    throw new InvalidStateException(locator.driver(), "Only use setSelected on checkbox/option/radio");
   }
  }
  if (element.getAttribute("readonly") != null || element.getAttribute("disabled") != null) {
   throw new InvalidStateException(locator.driver(), "Cannot change value of readonly/disabled element");
  }
  if (element.isSelected() != selected) {
   click.execute(proxy, locator, NO_ARGS);
  }
  return proxy;
 }
}
origin: spring-io/initializr

private Object getInputValue(WebElement input) {
  Object value = null;
  String type = input.getAttribute("type");
  if ("select".equals(input.getTagName())) {
    Select select = new Select(input);
    if (select.isMultiple()) {
      value = select.getAllSelectedOptions().stream().map(this::getValue)
          .collect(Collectors.toList());
    }
    else {
      value = getValue(select.getFirstSelectedOption());
    }
  }
  else if (Arrays.asList("checkbox", "radio").contains(type)) {
    if (input.isSelected()) {
      value = getValue(input);
    }
    else {
      if (Objects.equals(type, "checkbox")) {
        value = false;
      }
    }
  }
  else {
    value = getValue(input);
  }
  return value;
}
origin: TEAMMATES/teammates

public void verifyUnclickable(WebElement element) {
  if (element.getTagName().equals("a")) {
    assertTrue(element.getAttribute("class").contains("disabled"));
  } else {
    assertNotNull(element.getAttribute("disabled"));
  }
}
origin: com.atlassian.selenium/atlassian-webdriver-core

@Override
public boolean matchesSafely(WebElement item)
{
  return expectedTagName.equals(item.getTagName());
}
origin: net.serenity-bdd/serenity-core

private static boolean isAFormElement(WebElement element) {
  if ((element == null) || (element.getTagName() == null)) {
    return false;
  }
  String tag = element.getTagName().toLowerCase();
  return HTML_FORM_TAGS.contains(tag);
}
origin: com.cognifide.qa.bb/bb-core

private boolean isUploadField(WebElement webElement) {
 boolean tagIsInput = "input".equals(webElement.getTagName());
 boolean typeIsFile = "file".equals(webElement.getAttribute("type"));
 return tagIsInput && typeIsFile;
}
origin: stackoverflow.com

 try{
    WebElement byId = driver.findElement(By.id("by-id"));

    System.out.println(byId.getTagName());

    System.out.println("get the text for web element with id='by-id' ");
    System.out.println("------------------------------------------------------------");
    System.out.println(byId.getText());
    System.out.println("------------------------------------------------------------");
    System.out.println(byId.getAttribute("id"));
    System.out.println(byId.getCssValue("font-size"));
  }
}
origin: com.epam.jdi/jdi-light

private boolean isActual(T element) {
  try {
    element.get().getTagName();
    return true;
  } catch (Exception ex) { return false; }
}
@JDIAction(level = DEBUG)
origin: cz.etnetera/seb

/**
 * Returns true if at least one of the context elements matches the tag.
 * 
 * @param tag The tag to match
 * @return true if at least one of the context elements matches the tag
 */
public boolean is(String tag) {
  return getWebElement().getTagName().equalsIgnoreCase(tag);
}
origin: com.infotel.seleniumRobot/core

protected void blur() {
  if (SeleniumTestsContextManager.isWebTest() && "input".equalsIgnoreCase(element.getTagName())) {
    try {
      ((JavascriptExecutor) driver).executeScript("arguments[0].blur();", element);
    } catch (Exception e) {	
      logger.error(e);
    }
  }
}
 
origin: com.epam.jdi/jdi-light

private Select getSelectElement(String action) {
  WebElement root = get();
  if (root.getTagName().contains("select"))
    return new Select(root);
  throw exception(SELECT_ERROR, action, this);
}
origin: org.seleniumhq.webdriver/webdriver-remote-server

public ResultType call() throws Exception {
 response = newResponse();
 response.setValue(getElement().getTagName());
 return ResultType.SUCCESS;
}
org.openqa.seleniumWebElementgetTagName

Javadoc

Get the tag name of this element. Not the value of the name attribute: will return "input" for the element <input name="foo" />.

Popular methods of WebElement

  • getText
    Get the visible (i.e. not hidden by CSS) text of this element, including sub-elements.
  • click
    Click this element. If this causes a new page to load, you should discard all references to this ele
  • sendKeys
    Use this method to simulate typing into an element, which may set its value.
  • getAttribute
    Get the value of the given attribute of the element. Will return the current value, even if this has
  • clear
    If this element is a text entry element, this will clear the value. Has no effect on other elements.
  • isDisplayed
    Is this element displayed or not? This method avoids the problem of having to parse an element's "st
  • findElements
    Find all elements within the current context using the given mechanism. When using xpath be aware th
  • isSelected
    Determine whether or not this element is selected or not. This operation only applies to input eleme
  • findElement
    Find the first WebElement using the given method. See the note in #findElements(By) about finding vi
  • isEnabled
    Is the element currently enabled or not? This will generally return true for everything but disabled
  • getLocation
    Where on the page is the top left-hand corner of the rendered element?
  • submit
    If this current element is a form, or an element within a form, then this will be submitted to the r
  • getLocation,
  • submit,
  • getSize,
  • getCssValue,
  • getRect,
  • getScreenshotAs,
  • getValue,
  • setSelected,
  • toggle

Popular in Java

  • Making http post requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • startActivity (Activity)
  • onCreateOptionsMenu (Activity)
  • ObjectMapper (com.fasterxml.jackson.databind)
    This mapper (or, data binder, or codec) provides functionality for converting between Java objects (
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • String (java.lang)
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • JFrame (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now