Java Code Examples for com.gargoylesoftware.htmlunit.html.DomElement#getId()
The following examples show how to use
com.gargoylesoftware.htmlunit.html.DomElement#getId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractList.java From htmlunit with Apache License 2.0 | 6 votes |
/** * Adds the ids of the collection's elements to the idList. * @param idList the list to add the ids to * @param elements the collection's elements */ protected void addElementIds(final List<String> idList, final List<DomNode> elements) { int index = 0; for (final DomNode next : elements) { if (next instanceof DomElement) { final DomElement element = (DomElement) next; final String name = element.getAttributeDirect("name"); if (name != DomElement.ATTRIBUTE_NOT_DEFINED) { idList.add(name); } final String id = element.getId(); if (id != DomElement.ATTRIBUTE_NOT_DEFINED) { idList.add(id); } } if (!getBrowserVersion().hasFeature(JS_NODE_LIST_ENUMERATE_FUNCTIONS)) { idList.add(Integer.toString(index)); } index++; } }
Example 2
Source File: LabelsHelper.java From htmlunit with Apache License 2.0 | 6 votes |
/** * This is overridden instead of {@link #computeElements()} in order to prevent caching at all. * * {@inheritDoc} */ @Override public List<DomNode> getElements() { final List<DomNode> response = new ArrayList<>(); final DomElement domElement = (DomElement) getDomNodeOrDie(); for (DomNode parent = domElement.getParentNode(); parent != null; parent = parent.getParentNode()) { if (parent instanceof HtmlLabel) { response.add(parent); } } final String id = domElement.getId(); if (id != DomElement.ATTRIBUTE_NOT_DEFINED) { for (final DomElement label : domElement.getHtmlPageOrNull().getElementsByTagName("label")) { if (id.equals(label.getAttributeDirect("for"))) { response.add(label); } } } return response; }
Example 3
Source File: AbstractList.java From HtmlUnit-Android with Apache License 2.0 | 6 votes |
/** * Adds the ids of the collection's elements to the idList. * @param idList the list to add the ids to * @param elements the collection's elements */ protected void addElementIds(final List<String> idList, final List<DomNode> elements) { int index = 0; for (final DomNode next : elements) { if (next instanceof DomElement) { final DomElement element = (DomElement) next; final String name = element.getAttributeDirect("name"); if (name != DomElement.ATTRIBUTE_NOT_DEFINED) { idList.add(name); } final String id = element.getId(); if (id != DomElement.ATTRIBUTE_NOT_DEFINED) { idList.add(id); } } if (!getBrowserVersion().hasFeature(JS_NODE_LIST_ENUMERATE_FUNCTIONS)) { idList.add(Integer.toString(index)); } index++; } }
Example 4
Source File: LabelsHelper.java From HtmlUnit-Android with Apache License 2.0 | 6 votes |
/** * This is overridden instead of {@link #computeElements()} in order to prevent caching at all. * * {@inheritDoc} */ @Override public List<DomNode> getElements() { final List<DomNode> response = new ArrayList<>(); final DomElement domElement = (DomElement) getDomNodeOrDie(); for (DomNode parent = domElement.getParentNode(); parent != null; parent = parent.getParentNode()) { if (parent instanceof HtmlLabel) { response.add(parent); } } final String id = domElement.getId(); if (id != DomElement.ATTRIBUTE_NOT_DEFINED) { for (final DomElement label : domElement.getHtmlPageOrNull().getElementsByTagName("label")) { if (id.equals(label.getAttributeDirect("for"))) { response.add(label); } } } return response; }
Example 5
Source File: AbstractList.java From htmlunit with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public boolean has(final String name, final Scriptable start) { // let's Rhino work normally if current instance is the prototype if (isPrototype()) { return super.has(name, start); } try { return has(Integer.parseInt(name), start); } catch (final NumberFormatException e) { // Ignore. } if ("length".equals(name)) { return true; } final BrowserVersion browserVersion = getBrowserVersion(); if (browserVersion.hasFeature(JS_NODE_LIST_ENUMERATE_FUNCTIONS)) { final JavaScriptConfiguration jsConfig = getWindow().getWebWindow().getWebClient() .getJavaScriptEngine().getJavaScriptConfiguration(); if (jsConfig.getClassConfiguration(getClassName()).getFunctionKeys().contains(name)) { return true; } } if (browserVersion.hasFeature(JS_NODE_LIST_ENUMERATE_CHILDREN)) { for (final Object next : getElements()) { if (next instanceof DomElement) { final DomElement element = (DomElement) next; if (name.equals(element.getAttributeDirect("name"))) { return true; } final String id = element.getId(); if (name.equals(id)) { return true; } } } } return getWithPreemption(name) != NOT_FOUND; }
Example 6
Source File: AbstractList.java From HtmlUnit-Android with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public boolean has(final String name, final Scriptable start) { // let's Rhino work normally if current instance is the prototype if (isPrototype()) { return super.has(name, start); } try { return has(Integer.parseInt(name), start); } catch (final NumberFormatException e) { // Ignore. } if ("length".equals(name)) { return true; } final BrowserVersion browserVersion = getBrowserVersion(); if (browserVersion.hasFeature(JS_NODE_LIST_ENUMERATE_FUNCTIONS)) { final JavaScriptConfiguration jsConfig = getWindow().getWebWindow().getWebClient() .getJavaScriptEngine().getJavaScriptConfiguration(); if (jsConfig.getClassConfiguration(getClassName()).getFunctionKeys().contains(name)) { return true; } } if (browserVersion.hasFeature(JS_NODE_LIST_ENUMERATE_CHILDREN)) { for (final Object next : getElements()) { if (next instanceof DomElement) { final DomElement element = (DomElement) next; if (name.equals(element.getAttributeDirect("name"))) { return true; } final String id = element.getId(); if (name.equals(id)) { return true; } } } } return getWithPreemption(name) != NOT_FOUND; }