Пример #1
0
  public boolean executeInput(EmbeddedBrowser browser, StateVertex vertex, BioFuzzFieldInput in) {
    log.debug("executeInput(EmbeddedBrowser browser,StateVertex vertex,Input in) ");
    log.debug("Input: " + in.toString());
    assert (browser != null);
    assert (vertex != null);
    assert (in != null);
    switch (in.getAction()) {
      case TEXT_INPUT:
        boolean ret = true;
        for (String elementId : in.getElementIds()) {
          ret = ret & xpathInput(browser, vertex, elementId, in.getInputValue());
        }
        return ret;
      case CLICK:
        return xpathEvent(browser, vertex, in.getElementId(0), EventType.click);
      case GO_TO_URL:
        try {
          browser.goToUrl(new URL(in.getInputValue()));
          return true;
        } catch (MalformedURLException e) {
          // TODO Auto-generated catch block
          return false;
        }
    }

    return false;
  }
Пример #2
0
  public boolean executeInput(EmbeddedBrowser browser, BioFuzzFieldInput in) {
    log.info("executeInput(EmbeddedBrowser browser,Input in)");
    assert (browser != null);
    assert (in != null);

    switch (in.getAction()) {
      case TEXT_INPUT:
        log.info("text input");
        boolean ret = true;
        for (String elementId : in.getElementIds()) {
          log.debug("execute input for" + elementId);
          ret = ret && xpathInput(browser, elementId, in.getInputValue());
        }
        return ret;
      case CLICK:
        log.debug("click");
        assert (in.getElementIds().size() > 0);
        return xpathEvent(browser, in.getElementId(0), EventType.click);
      case GO_TO_URL:
        log.debug("go to url");
        try {
          browser.goToUrl(new URL(in.getInputValue()));
          return true;
        } catch (MalformedURLException e) {
          // TODO Auto-generated catch block
          return false;
        }
      default:
        break;
    }

    return false;
  }
  /**
   * initialize the current used controller. 1. build the index state, 2. create a new CrawlSession
   * from the new index state and the golden standard, 3. run revisitedStatesPlugins on the new
   * found index.
   *
   * @param golderStandard the SFG containing all the original states & edges.
   * @param goldenIndexState the golden/original index state.
   */
  private void initializeController(StateFlowGraph golderStandard, StateVertix goldenIndexState) {
    EmbeddedBrowser browser = null;
    try {
      browser = getBrowserPool().requestBrowser();
    } catch (InterruptedException e) {
      LOGGER.error("The request for a browser was interuped", e);
    }

    browser.goToUrl(this.getConfigurationReader().getCrawlSpecificationReader().getSiteUrl());
    doBrowserWait(browser);

    /** Build the index state */
    StateVertix indexState =
        new StateVertix(
            browser.getCurrentUrl(), "index", browser.getDom(), getStrippedDom(browser));

    /** Build the CrawlSession */
    CrawlSession session =
        new CrawlSession(
            getBrowserPool(),
            golderStandard,
            indexState,
            getStartCrawl(),
            getConfigurationReader());
    setSession(session);

    // Because of new Index must be checked run the onRevisitedStatesPlugins
    CrawljaxPluginsUtil.runOnRevisitStatePlugins(session, goldenIndexState);

    // Release the browser
    this.getBrowserPool().freeBrowser(browser);
  }