Package com.crawljax.core.state

Examples of com.crawljax.core.state.StateVertex


   */
  public StateVertex crawlIndex() {
    LOG.debug("Setting up vertex of the index page");
    browser.goToUrl(url);
    plugins.runOnUrlLoadPlugins(context);
    StateVertex index = vertexFactory.createIndex(url.toString(), browser.getStrippedDom(),
                    stateComparator.getStrippedDom(browser));
    Preconditions.checkArgument(index.getId() == StateVertex.INDEX_ID,
            "It seems some the index state is crawled more than once.");

    LOG.debug("Parsing the index for candidate elements");
    ImmutableList<CandidateElement> extract = candidateExtractor.extract(index);

View Full Code Here


    List<Map<String, String>> elements =
            Lists.newArrayListWithCapacity(candidateElements.size());

    for (CandidateElementPosition element : candidateElements) {
      Eventable eventable = getEventableByCandidateElementInState(state, element);
      StateVertex toState = null;
      Map<String, String> elementMap = new HashMap<String, String>();
      elementMap.put("xpath", element.getXpath());
      elementMap
              .put("left", "" + (element.getLeft() - 3));
      elementMap.put("top", "" + (element.getTop() - 3));
      elementMap.put("width", "" + (element.getWidth() + 2));
      elementMap.put("height", "" + (element.getHeight() + 2));
      if (eventable != null) {
        toState = eventable.getTargetStateVertex();
      }
      if (toState != null) {
        elementMap.put("targetname", toState.getName());
        if (getStateNumber(toState.getName()) < getStateNumber(state.getName())) {
          // state already found
          elementMap.put("color", COLOR_A_PREVIOUS_STATE);
        } else {
          // new state
          elementMap.put("color", COLOR_NEW_STATE);
View Full Code Here

    return elements;
  }

  private Eventable getEventableByCandidateElementInState(State state,
          CandidateElementPosition element) {
    StateVertex vertex = visitedStates.get(state.getName());
    for (Eventable eventable : sfg.getOutgoingClickables(vertex)) {
      // TODO Check if element.getIdentification().getValue() is correct replacement for
      // element.getXpath()
      if (eventable.getIdentification().getValue().equals(element.getXpath())) {
        return eventable;
View Full Code Here

  }

  private void pollAndHandleCrawlTasks() throws InterruptedException {
    try {
      LOG.debug("Awaiting task");
      StateVertex crawlTask = candidates.awaitNewTask();
      int activeConsumers = runningConsumers.incrementAndGet();
      LOG.debug("There are {} active consumers", activeConsumers);
      handleTask(crawlTask);
    } catch (RuntimeException e) {
      LOG.error("Cound not complete state crawl: " + e.getMessage(), e);
View Full Code Here

  @Override
  public CrawlSession call() {
    setMaximumCrawlTimeIfNeeded();
    plugins.runPreCrawlingPlugins(config);
    CrawlTaskConsumer firstConsumer = consumerFactory.get();
    StateVertex firstState = firstConsumer.crawlIndex();
    crawlSessionProvider.setup(firstState);
    plugins.runOnNewStatePlugins(firstConsumer.getContext(), firstState);
    executeConsumers(firstConsumer);
    return crawlSessionProvider.get();
  }
View Full Code Here

   */
  private void goBackExact() throws CrawljaxException {
    /**
     * Thread safe
     */
    StateVertex curState = controller.getSession().getInitialState();

    for (Eventable clickable : backTrackPath) {

      if (!controller.getElementChecker().checkCrawlCondition(getBrowser())) {
        return;
View Full Code Here

    }

    LOGGER.info("Executing " + eventable.getEventType() + " on element: " + eventable
            + "; State: " + this.getStateMachine().getCurrentState().getName());
    if (this.fireEvent(eventable)) {
      StateVertex newState =
              new StateVertex(getBrowser().getCurrentUrl(), controller.getSession()
                      .getStateFlowGraph().getNewStateName(), getBrowser().getDom(),
                      this.controller.getStrippedDom(getBrowser()));
      if (isDomChanged(this.getStateMachine().getCurrentState(), newState)) {
        // Dom is changed, so data might need be filled in again
        controller.getSession().addEventableToCrawlPath(eventable);
View Full Code Here

  private ClickResult crawlAction(CandidateCrawlAction action) throws CrawljaxException {
    CandidateElement candidateElement = action.getCandidateElement();
    EventType eventType = action.getEventType();

    StateVertex orrigionalState = this.getStateMachine().getCurrentState();

    if (candidateElement.allConditionsSatisfied(getBrowser())) {
      ClickResult clickResult = clickTag(new Eventable(candidateElement, eventType));
      switch (clickResult) {
        case cloneDetected:
View Full Code Here

    if (!checkConstraints()) {
      return false;
    }

    // Store the currentState to be able to 'back-track' later.
    StateVertex orrigionalState = this.getStateMachine().getCurrentState();

    if (orrigionalState.searchForCandidateElements(candidateExtractor, configurationReader
            .getTagElements(), configurationReader.getExcludeTagElements(),
            configurationReader.getCrawlSpecificationReader().getClickOnce())) {
      // Only execute the preStateCrawlingPlugins when it's the first time
      LOGGER.info("Starting preStateCrawlingPlugins...");
      List<CandidateElement> candidateElements =
              orrigionalState.getUnprocessedCandidateElements();
      CrawljaxPluginsUtil.runPreStateCrawlingPlugins(controller.getSession(),
              candidateElements);
      // update crawlActions
      orrigionalState.filterCandidateActions(candidateElements);
    }

    CandidateCrawlAction action =
            orrigionalState.pollCandidateCrawlAction(this, crawlQueueManager);
    while (action != null) {
      if (depthLimitReached(depth)) {
        return true;
      }

      if (!checkConstraints()) {
        return false;
      }
      ClickResult result = this.crawlAction(action);
      orrigionalState.finishedWorking(this, action);
      switch (result) {
        case newState:
          return newStateDetected(orrigionalState);
        case cloneDetected:
          return true;
        default:
          break;
      }
      action = orrigionalState.pollCandidateCrawlAction(this, crawlQueueManager);
    }
    return true;
  }
View Full Code Here

    goToInitialURL();

    /**
     * Build the index state
     */
    StateVertex indexState =
            new StateVertex(this.getBrowser().getCurrentUrl(), "index", this.getBrowser()
                    .getDom(), controller.getStrippedDom(this.getBrowser()));

    /**
     * Build the StateFlowGraph
     */
 
View Full Code Here

TOP

Related Classes of com.crawljax.core.state.StateVertex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.