/** * Returns the element ID. * @return the ID of this element */ public String jsxGet_id() { return getDomNodeOrDie().getId(); }
/** * Returns the element ID. * @return the ID of this element */ public String jsxGet_id() { return getDomNodeOrDie().getId(); }
/** * Returns a list of ids (strings) that correspond to the tabbable elements * in this page. Return them in the same order specified in {@link #getTabbableElements} * * @return the list of id's */ public List<String> getTabbableElementIds() { final List<String> list = new ArrayList<>(); for (final HtmlElement element : getTabbableElements()) { list.add(element.getId()); } return Collections.unmodifiableList(list); }
/** * Returns the element ID. * @return the ID of this element */ public String jsxGet_id() { return getDomNodeOrDie().getId(); }
/** * Returns a list of ids (strings) that correspond to the tabbable elements * in this page. Return them in the same order specified in {@link #getTabbableElements} * * @return the list of id's */ public List<String> getTabbableElementIds() { final List<String> list = new ArrayList<>(); for (final HtmlElement element : getTabbableElements()) { list.add(element.getId()); } return Collections.unmodifiableList(list); }
/** * Verifies that all element IDs in the specified page are unique. * * @param page the page to check */ public static void assertAllIdAttributesUnique(final HtmlPage page) { final List<String> list = new ArrayList<>(); for (final HtmlElement element : page.getHtmlElementDescendants()) { final String id = element.getId(); if (id != null && !id.isEmpty()) { if (list.contains(id)) { throw new AssertionError("The element ID '" + id + "' is not unique."); } list.add(id); } } }
/** * Verifies that all element IDs in the specified page are unique. * * @param page the page to check */ public static void assertAllIdAttributesUnique(final HtmlPage page) { final List<String> list = new ArrayList<>(); for (final HtmlElement element : page.getHtmlElementDescendants()) { final String id = element.getId(); if (id != null && !id.isEmpty()) { if (list.contains(id)) { throw new AssertionError("The element ID '" + id + "' is not unique."); } list.add(id); } } }
protected <T extends HtmlElement> T getFirstMatchingElement(HtmlPage page, Class<T> elementClass, String id) { Set<T> inputs = getElements(page.getBody(), elementClass); for (T input : inputs) { if (input.getId().contains(id)) { return input; } } return null; }
protected <T extends HtmlElement> T getFirstMatchingElement(HtmlPage page, Class<T> elementClass, String id) { Set<T> inputs = getElements(page.getBody(), elementClass); for (T input : inputs) { if (input.getId().contains(id)) { return input; } } return null; }
/** * 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) { final HtmlElement element = (HtmlElement) next; final String name = element.getAttributeDirect("name"); if (name != DomElement.ATTRIBUTE_NOT_DEFINED) { idList.add(name); } else { final String id = element.getId(); if (id != DomElement.ATTRIBUTE_NOT_DEFINED) { idList.add(id); } else { idList.add(Integer.toString(index)); } } index++; } }
protected <T extends HtmlElement> T getFirstMatchingElement(HtmlPage page, Class<T> elementClass, String id) { Set<T> inputs = getElements(page.getBody(), elementClass); for (T input : inputs) { if (input.getId().contains(id)) { return input; } } return null; }
/** * 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) { final HtmlElement element = (HtmlElement) next; final String name = element.getAttributeDirect("name"); if (name != DomElement.ATTRIBUTE_NOT_DEFINED) { idList.add(name); } else { final String id = element.getId(); if (id != DomElement.ATTRIBUTE_NOT_DEFINED) { idList.add(id); } else { idList.add(Integer.toString(index)); } } index++; } }
/** * Note that this method doesn't return the first element whose id equals specified id but the one whose id contains * specified id! * * @param page * @param elementClass * @param id * @return the first element whose id contains specified id */ protected <T extends HtmlElement> T getFirstMatchingElement(HtmlPage page, Class<T> elementClass, String id) { Set<T> inputs = getElements(page.getBody(), elementClass); for (T input : inputs) { if (input.getId().contains(id)) { return input; } } return null; }
/** * An IE-only method which copies all custom attributes from the specified source element * to this element. * @param source the source element from which to copy the custom attributes * @param preserveIdentity if {@code false}, the <tt>name</tt> and <tt>id</tt> attributes are not copied */ @JsxFunction(IE) public void mergeAttributes(final HTMLElement source, final Object preserveIdentity) { final HtmlElement src = source.getDomNodeOrDie(); final HtmlElement target = getDomNodeOrDie(); // Merge ID and name if we aren't preserving identity. if (preserveIdentity instanceof Boolean && !((Boolean) preserveIdentity).booleanValue()) { target.setId(src.getId()); target.setAttribute("name", src.getAttributeDirect("name")); } }
/** * An IE-only method which copies all custom attributes from the specified source element * to this element. * @param source the source element from which to copy the custom attributes * @param preserveIdentity if {@code false}, the <tt>name</tt> and <tt>id</tt> attributes are not copied */ @JsxFunction(IE) public void mergeAttributes(final HTMLElement source, final Object preserveIdentity) { final HtmlElement src = source.getDomNodeOrDie(); final HtmlElement target = getDomNodeOrDie(); // Merge ID and name if we aren't preserving identity. if (preserveIdentity instanceof Boolean && !((Boolean) preserveIdentity).booleanValue()) { target.setId(src.getId()); target.setAttribute("name", src.getAttributeDirect("name")); } }
/** * Indicates if the element can be reached by id or name in expressions like "myForm.myField". * @param element the element to test * @param name the name used to address the element * @return {@code true} if this element matches the conditions */ private boolean isAccessibleByIdOrName(final HtmlElement element, final String name) { if (element instanceof FormFieldWithNameHistory && !(element instanceof HtmlImageInput)) { if (element.getEnclosingForm() != getHtmlForm()) { return false; // nested forms } if (name.equals(element.getId())) { return true; } final FormFieldWithNameHistory elementWithNames = (FormFieldWithNameHistory) element; if (getBrowserVersion().hasFeature(FORMFIELD_REACHABLE_BY_ORIGINAL_NAME)) { if (name.equals(elementWithNames.getOriginalName())) { return true; } } else if (name.equals(element.getAttributeDirect("name"))) { return true; } if (getBrowserVersion().hasFeature(FORMFIELD_REACHABLE_BY_NEW_NAMES) && elementWithNames.getNewNames().contains(name)) { return true; } } return false; }
/** * Indicates if the element can be reached by id or name in expressions like "myForm.myField". * @param element the element to test * @param name the name used to address the element * @return {@code true} if this element matches the conditions */ private boolean isAccessibleByIdOrName(final HtmlElement element, final String name) { if (element instanceof FormFieldWithNameHistory && !(element instanceof HtmlImageInput)) { if (element.getEnclosingForm() != getHtmlForm()) { return false; // nested forms } if (name.equals(element.getId())) { return true; } final FormFieldWithNameHistory elementWithNames = (FormFieldWithNameHistory) element; if (getBrowserVersion().hasFeature(FORMFIELD_REACHABLE_BY_ORIGINAL_NAME)) { if (name.equals(elementWithNames.getOriginalName())) { return true; } } else if (name.equals(element.getAttributeDirect("name"))) { return true; } if (getBrowserVersion().hasFeature(FORMFIELD_REACHABLE_BY_NEW_NAMES) && elementWithNames.getNewNames().contains(name)) { return true; } } return false; }
target.setId(src.getId()); target.setAttribute("name", src.getAttribute("name"));
target.setId(src.getId()); target.setAttribute("name", src.getAttribute("name"));
target.setId(src.getId()); target.setAttribute("name", src.getAttribute("name"));