/** * Creates an instance and sets its parent scope to the one of the provided element. * * @param element the element to which this style is bound */ CSSPrimitiveValue(final HTMLElement element, final org.w3c.dom.css.CSSPrimitiveValue cssValue) { super(element, cssValue); setParentScope(element.getParentScope()); setPrototype(getPrototype(getClass())); setDomNode(element.getDomNodeOrNull(), false); wrappedCssPrimitiveValue_ = cssValue; }
private static void changeContentEditableValueInHtmlUnit( WebDriver driver, WebElement element, String value) { // we resort to JavaScript when it is enabled if (((HtmlUnitDriver) driver).isJavascriptEnabled()) { JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript( "arguments[0]['innerText' in arguments[0] ? 'innerText' : 'textContent'] = arguments[1];", element, value); } else { // or use reflection if JS is not enabled // (this method is not preferred as it relies on HtmlUnit's internals, which can change // without notice) try { // #HtmlUnit #reflection #hack Method getElementMethod = org.openqa.selenium.htmlunit.HtmlUnitWebElement.class.getDeclaredMethod("getElement"); getElementMethod.setAccessible(true); HtmlElement he = (HtmlElement) getElementMethod.invoke(element); HTMLElement e = (HTMLElement) he.getScriptObject(); e.setInnerText(value); } catch (Exception e) { LOGGER.warn("Unable to set HtmlUnitWebElement's innerText.", e); } } }
/** * Returns this box object's element's previous sibling. * * @return this box object's element's previous sibling */ @JsxGetter public Object getPreviousSibling() { return element_.getPreviousSibling(); }
/** * Returns this box object's element's next sibling. * * @return this box object's element's next sibling */ @JsxGetter public Object getNextSibling() { return element_.getNextSibling(); }
/** * Returns this box object's element's last child. * * @return this box object's element's last child */ @JsxGetter public Object getLastChild() { return element_.getLastChild(); }
/** * Returns the height of this box object's element, including padding, excluding margin and * border. * * @return the height of this box object's element, including padding, excluding margin and border */ @JsxGetter public int getHeight() { return element_.getClientHeight(); }
/** * Returns the width of this box object's element, including padding, excluding margin and border. * * @return the width of this box object's element, including padding, excluding margin and border */ @JsxGetter public int getWidth() { return element_.getClientWidth(); }
/** * Returns the Y position of this box object's element. * * @return the Y position of this box object's element */ @JsxGetter public int getY() { return element_.getPosY(); }