Example #1
0
  /**
   * Scrolls to a component on the page
   *
   * @param o component to be scrolled to
   */
  protected void scrollToComponent(SGuiObject o) {
    String xpath = sUtils.navigateFrames(o.getLocator(), selenium);
    long left = 0;
    long top = 0;

    try {
      left = selenium.getElementPositionLeft(xpath).longValue();
    } catch (Exception x) {
    }
    try {
      top = selenium.getElementPositionTop(xpath).longValue();
    } catch (Exception x) {
    }

    String eval = selenium.getEval("SAFSgetClientScrollInfo();");
    String[] values = eval.split(";");

    long width = 0;
    long height = 0;
    long scrollTop = 0;
    long scrollLeft = 0;
    try {
      width = Integer.parseInt(values[0]);
    } catch (Exception x) {;
    }
    try {
      height = Integer.parseInt(values[1]);
    } catch (Exception x) {;
    }
    try {
      scrollLeft = Integer.parseInt(values[2]);
    } catch (Exception x) {;
    }
    try {
      scrollTop = Integer.parseInt(values[3]);
    } catch (Exception x) {;
    }

    if ((left < scrollLeft || left > scrollLeft + width)
        || (top < scrollTop || top > scrollTop + height)) {
      eval = selenium.getEval("window.scrollTo(" + left + "," + top + ");");
    }
  }