/** Click top left, can be modified to click in the middle */
  public Point getLocation() {
    assertElementNotStale();

    String coordinates =
        debugger.callFunctionOnObject(
            "var coords = "
                + OperaAtom.GET_LOCATION
                + "(locator); return coords.x + ',' + coords.y;",
            objectId);

    // TODO: The goog.dom.getDocumentScrollElement_() function the Google closure library doesn't
    // return the document for SVG documents. This is used by the above atom. In this case the
    // coordinates string will be empty, so we use this fallback to get the coordinates. Hopefully
    // a fix will be forthcoming in the closure library.
    if (coordinates.isEmpty()) {
      logger.warning("Falling back to non-atom positioning code in getLocation");
      coordinates =
          debugger.callFunctionOnObject(
              "var coords = locator.getBoundingClientRect();"
                  + "return (coords.left-window.pageXOffset)+','+(coords.top-window.pageYOffset)",
              objectId);
    }

    String[] location = coordinates.split(",");
    return new Point(Integer.valueOf(location[0]), Integer.valueOf(location[1]));
  }
  public Dimension getSize() {
    assertElementNotStale();

    String widthAndHeight =
        debugger.callFunctionOnObject(
            "var s=" + OperaAtom.GET_SIZE + "(locator);return s.width+','+s.height;", objectId);

    String[] dimension = widthAndHeight.split(",");
    return new Dimension(Integer.valueOf(dimension[0]), Integer.valueOf(dimension[1]));
  }
 public Point getLocationInViewPort() {
   String coordinates =
       debugger.callFunctionOnObject(
           "locator.scrollIntoView();\n"
               + "var x = 0, y = 0;\n"
               + "if(window.top !== window.self) {\n"
               + "x = (window.screenLeft - window.top.screenLeft) + window.scrollX;\n"
               + "y = (window.screenTop - window.top.screenTop) + window.scrollY;\n"
               + "}\n"
               + "return (( x + locator.getBoundingClientRect().left) + ',' + ( y + locator.getBoundingClientRect().top));\n",
           objectId);
   String[] location = coordinates.split(",");
   return new Point(Integer.valueOf(location[0]), Integer.valueOf(location[1]));
 }
 /**
  * Executes the given script with the element's object ID, but does not parse the response.
  *
  * @param script the script to execute
  */
 private void executeMethod(String script) {
   parent.assertConnected();
   debugger.callFunctionOnObject(script, objectId, false);
 }
 /**
  * Calls the method and parses the result, the result must be a string
  *
  * @param method the method to call
  * @return response of EcmaScript in string presentation
  */
 public final String callMethod(String method) {
   parent.assertConnected();
   return debugger.callFunctionOnObject(method, objectId);
 }
 /**
  * Evaluates the given script with object ID, parses the result and returns the result object.
  *
  * @param script the script to execute
  * @return a parsed result object from the executor
  */
 private Object evaluateMethod(String script) {
   return debugger.callFunctionOnObject(script, objectId, true);
 }
Esempio n. 7
0
 /**
  * Calls the method and parses the result, the result must be a string
  *
  * @param method the method to call
  * @return response of EcmaScript in string presentation
  */
 public final String callMethod(String method) {
   return debugger.callFunctionOnObject(method, objectId);
 }
Esempio n. 8
0
 /**
  * Executes the given script with the element's object ID, but does not parse the response.
  *
  * @param script the script to execute
  */
 private void executeMethod(String script) {
   debugger.callFunctionOnObject(script, objectId, false);
 }