Beispiel #1
0
  public boolean highlight(SPCTreeNode node) {
    String dbgmsg = "WDSPC.highlight ";
    String xpath = node.xpath;
    String scriptCommand = null;
    boolean highlighted = true;

    // CANAGL attempt at setFocus()?
    try {
      selenium.manage().window().setPosition(selenium.manage().window().getPosition());
    } catch (NullPointerException ignore) {
      if (selenium == null) {
        Log.warn(dbgmsg + "did not find a non-null selenium WebDriver to focus!");
      } else {
        Log.warn(
            dbgmsg
                + "did not find a non-null WebDriver window() to manage() for get/set Position!");
      }
    }

    try {
      String rs = node.getRecognitionString();
      if (rs == null || rs.length() == 0) {
        Log.debug(dbgmsg + "did not find stored recognition string. Switching to XPATH.");
        rs = "XPATH=" + xpath;
      }
      utils.setWDTimeoutLock();
      utils.setWDTimeout(0);

      WebElement item = SearchObject.getObject(rs);
      if (item == null) {
        Log.debug(dbgmsg + "did not find the WebElement using recognition string: " + rs);
        return false;
      }
      highlighted = SearchObject.highlight(item);

    } catch (Exception e) {
      Log.warn(dbgmsg + e + getClass().getSimpleName() + ": " + e.getMessage());
      highlighted = false;
    } finally {
      utils.resetWDTimeout();
      utils.resetWDTimeoutLock();
    }

    return highlighted;
  }