Package net.sf.sahi.rhino

Examples of net.sf.sahi.rhino.ScriptRunner



public class TestReporter {
    public void logTestResult(final HttpRequest request) {
        Session session = request.session();
        ScriptRunner scriptRunner = session.getScriptRunner();
        if (scriptRunner == null) return;
    Report report = scriptRunner.getReport();
        if (report != null) {
            report.addResult(SahiScript.stripSahiFromFunctionNames(request.getParameter("msg")), request.getParameter("type"), request.getParameter("debugInfo"), request.getParameter("failureMsg"));
        }
    }
View Full Code Here


      }
    }   
   
    public HttpResponse start(final HttpRequest request){
    Session session = request.session();
        session.setScriptRunner(new ScriptRunner());     
      return new Player().autoJava(request);
    }   
View Full Code Here

      return new Player().autoJava(request);
    }   
   
    public void restart(final HttpRequest request) {
      Session session = request.session();
        session.setScriptRunner(new ScriptRunner());     
      session.setIsPlaying(true);
    session.setIsReadyForDriver(true);
    }
View Full Code Here

    return new SimpleHttpResponse(val != null ? val : "");
    }
   
    public HttpResponse doneStep(final HttpRequest request){
    Session session = request.session();
    ScriptRunner scriptRunner = session.getScriptRunner();
    if (scriptRunner == null){
      return new SimpleHttpResponse("error:Playback session not started. Verify that proxy is set on the browser.");
    }
    boolean done = scriptRunner.doneStep(""|| scriptRunner.isStopped();
    if (done){
      Status status = scriptRunner.getStatus();
      String browserException = scriptRunner.getBrowserException();
      if (browserException == null) browserException = "";
      if (status == Status.ERROR){
        return new SimpleHttpResponse("error:" +  browserException);
      } else if (status == Status.FAILURE) {
        return new SimpleHttpResponse("failure:" + browserException);       
View Full Code Here

  private static final Logger logger = Logger.getLogger("net.sf.sahi.command.RhinoRuntime");
 
    public HttpResponse eval(final HttpRequest request){
        Session session = request.session();
        String toEval = request.getParameter("toEval");
        ScriptRunner scriptRunner = session.getScriptRunner();
        String result = "null";
        if (scriptRunner instanceof RhinoScriptRunner){
          RhinoScriptRunner rsr = (RhinoScriptRunner) session.getScriptRunner();
          toEval = SahiScript.modifyFunctionNames(toEval);
      result = rsr.eval(toEval);
View Full Code Here

    private void startPlayback(final Session session, final boolean resetConditions, String paused) {
        if (resetConditions) {
            session.removeVariables(".*");
        }
        ScriptRunner scriptRunner = session.getScriptRunner();
    scriptRunner.setStatus(Status.RUNNING);
    session.setIsPlaying(true);
//        session.setVariable("sahi_play", "1");
        session.setVariable("sahi_paused", paused);
        session.setVariable("sahi_controller_tab", "playback");
      session.setVariable("sahi_scriptPath", scriptRunner.getScriptFilePath());
        scriptRunner.execute();
    }
View Full Code Here

//        ScriptRunner scriptRunner = session.getScriptRunner();
//      return new SimpleHttpResponse(scriptRunner != null && scriptRunner.getStatus() == Status.RUNNING ? "1" : "0");
    }
    public HttpResponse getCurrentStep(final HttpRequest request){
        Session session = request.session();
        ScriptRunner scriptRunner = session.getScriptRunner();
        if (scriptRunner == null) return new SimpleHttpResponse("{'type':'WAIT'}");
        String derivedName = request.getParameter("derivedName");
        String windowName = request.getParameter("windowName");
        String windowTitle = request.getParameter("windowTitle");
        String domain = request.getParameter("domain");
        String wasOpened = request.getParameter("wasOpened");
        //System.out.println("scriptRunner="+scriptRunner);
        return new SimpleHttpResponse(scriptRunner.getStepJSON(derivedName, windowName, windowTitle, domain, wasOpened));
    }
View Full Code Here

        return new SimpleHttpResponse(scriptRunner.getStepJSON(derivedName, windowName, windowTitle, domain, wasOpened));
    }

    public void markStepDone(final HttpRequest request){
        Session session = request.session();
        ScriptRunner scriptRunner = session.getScriptRunner();
        String failureMessage = request.getParameter("failureMsg");
        String type = request.getParameter("type");
        scriptRunner.markStepDone(request.getParameter("stepId"), ResultType.getType(type), failureMessage);
        session.set204(false);
//        try{
//          new TestReporter().logTestResult(request);
//        }catch(Exception e){
//            e.printStackTrace();
View Full Code Here

        return new SimpleHttpResponse(""+session.is204());
    }
   
    public void markStepInProgress(final HttpRequest request){
        Session session = request.session();
        ScriptRunner scriptRunner = session.getScriptRunner();
        String type = request.getParameter("type");
        scriptRunner.markStepInProgress(request.getParameter("stepId"), ResultType.getType(type));
    }
View Full Code Here

        return httpResponse;
    }

    public HttpResponse script(final HttpRequest request) {
        Session session = request.session();
        ScriptRunner scriptRunner = session.getScriptRunner();
    String s = null;
    if (scriptRunner != null) {
      if (scriptRunner.getScript() != null) {
        s = scriptRunner.getScript().getBrowserJS(); // Sahi Script
      } else {
        s = scriptRunner.getBrowserJS(); // Other drivers
      }
    }
    if (s == null) s = "";
        return new NoCacheHttpResponse(s);
    }
View Full Code Here

TOP

Related Classes of net.sf.sahi.rhino.ScriptRunner

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.