Package com.crawljax.core.state

Examples of com.crawljax.core.state.StateVertex


  /**
   * @return the currentState
   */
  public StateVertex getCurrentState() {
    StateVertex sv = tlState.get();
    if (sv == null) {
      tlState.set(getInitialState());
    } else {
      return sv;
    }
View Full Code Here


          final StateMachine stateMachine) {
    LOGGER.info("Running GuidedCrawlingPlugins...");
    for (Plugin plugin : CrawljaxPluginsUtil.PLUGINS) {
      if (plugin instanceof GuidedCrawlingPlugin) {
        LOGGER.info("Calling plugin " + plugin.getClass().getName());
        StateVertex currentState = session.getCurrentState();
        ((GuidedCrawlingPlugin) plugin).guidedCrawling(currentState, controller, session,
                exactEventPaths, stateMachine);
      }
    }
  }
View Full Code Here

    return graph.getShortestPath(graph.getInitialState(), crawlTask);
  }

  private void follow(CrawlPath path, StateVertex targetState)
          throws StateUnreachableException, CrawljaxException {
    StateVertex curState = context.getSession().getInitialState();

    for (Eventable clickable : path) {
      checkCrawlConditions(targetState);
      LOG.debug("Backtracking by executing {} on element: {}", clickable.getEventType(),
              clickable);
      curState = changeState(targetState, clickable);
      handleInputElements(clickable);
      tryToFireEvent(targetState, curState, clickable);
      checkCrawlConditions(targetState);
    }

    if (!curState.equals(targetState)) {
      throw new StateUnreachableException(targetState,
              "The path didn't result in the desired state but in state "
                      + curState.getName());
    }
  }
View Full Code Here

  private StateVertex changeState(StateVertex targetState, Eventable clickable) {
    boolean switched = stateMachine.changeState(clickable.getTargetStateVertex());
    if (!switched) {
      throw new StateUnreachableException(targetState, "Could not switch states");
    }
    StateVertex curState = clickable.getTargetStateVertex();
    crawlpath.add(clickable);
    return curState;
  }
View Full Code Here

  private void inspectNewState(Eventable event) {
    if (crawlerLeftDomain()) {
      LOG.debug("The browser left the domain. Going back one state...");
      goBackOneState();
    } else {
      StateVertex newState = stateMachine.newStateFor(browser);
      if (domChanged(event, newState)) {
        inspectNewDom(event, newState);
      } else {
        LOG.debug("Dom unchanged");
      }
View Full Code Here

      context.getSession().addCrawlPath(crawlpath.immutableCopy());
    }
  }

  private void parseCurrentPageForCandidateElements() {
    StateVertex currentState = stateMachine.getCurrentState();
    LOG.debug("Parsing DOM of state {} for candidate elements", currentState.getName());
    ImmutableList<CandidateElement> extract = candidateExtractor.extract(currentState);

    plugins.runPreStateCrawlingPlugins(context, extract, currentState);

    candidateActionCache.addActions(extract, currentState);
View Full Code Here

  private void goBackOneState() {
    LOG.debug("Going back one state");
    CrawlPath currentPath = crawlpath.immutableCopy();
    crawlpath = null;
    StateVertex current = stateMachine.getCurrentState();
    reset();
    follow(currentPath, current);
  }
View Full Code Here

   */
  public StateVertex crawlIndex() {
    LOG.debug("Setting up vertex of the index page");
    browser.goToUrl(url);
    plugins.runOnUrlLoadPlugins(context);
    StateVertex index =
            StateMachine.createIndex(url.toExternalForm(), 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

    assertThat(counterFor(OnUrlLoadPlugin.class), is(1));
  }

  @Test
  public void revisitStatePluginIsCalled() throws Exception {
    StateVertex currentState = mock(StateVertex.class);
    plugins.runOnRevisitStatePlugins(context, currentState);
    verify(onRevisitStatePlugin).onRevisitState(context, currentState);
    assertThat(counterFor(OnRevisitStatePlugin.class), is(1));
  }
View Full Code Here

    assertThat(counterFor(OnInvariantViolationPlugin.class), is(1));
  }

  @Test
  public void domChangeNotifierIsCalled() {
    StateVertex stateBefore = mock(StateVertex.class);
    Eventable eventable = mock(Eventable.class);
    StateVertex stateAfter = mock(StateVertex.class);
    String oldDom = "old";
    String newDom = "new";
    when(stateBefore.getDom()).thenReturn(oldDom);
    when(stateAfter.getDom()).thenReturn(newDom);

    plugins.runDomChangeNotifierPlugins(context, stateBefore, eventable, stateAfter);
    verify(domChange).isDomChanged(context, oldDom, eventable, newDom);

    assertThat(counterFor(DomChangeNotifierPlugin.class), is(1));
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.