/**
  * 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;
 }
示例#2
0
  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);
      }
    }
  }
示例#3
0
 /**
  * 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();
 }
示例#4
0
 /**
  * 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();
 }
示例#5
0
 /**
  * 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();
 }
示例#6
0
 /**
  * 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();
 }
示例#7
0
 /**
  * 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();
 }
示例#8
0
 /**
  * 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();
 }