Exemplo n.º 1
0
  public static void main(String[] args) throws JDOMException, IOException, TestCaseException {
    if (args.length == 0) {
      System.out.println("Please include a path for the selenium XML test file.");
    } else {
      SeleniumXml sel = new SeleniumXml();
      for (String arg : args) {
        if (arg.startsWith("-username")) {
          sel.username = arg.substring(10);
        } else if (arg.startsWith("-password")) {
          sel.password = arg.substring(10);
        } else {
          sel.testSourcePath = arg;
        }
      }

      File testFile = new File(args[0]);
      if (testFile.exists()) {
        System.err.println(" Argument : " + args[0]);
        System.err.println(" Full absolute path of file : " + testFile.getAbsolutePath());
        System.err.println(" Full canonical path of file : " + testFile.getCanonicalPath());

        sel.testCaseDirectory = sel.getFileDirectory(testFile.getAbsolutePath());
        System.err.println(" testCaseDirectory: " + sel.testCaseDirectory);
        sel.runTest(testFile.getAbsolutePath());
      } else {
        System.err.println("Test File is not exist :" + args[0]);
      }
    }
  }
Exemplo n.º 2
0
  /* call run test suite from webtool selenium */
  public static String runTestSuite(HttpServletRequest request, HttpServletResponse response) {
    Map parameters = UtilHttp.getParameterMap(request);
    String para = (String) parameters.get("testSuitePath");
    if (para == null) {
      System.out.println("Error message : Test suite Path  is null");
      return "success";
    }
    if (para.length() == 0) {
      System.out.println("Error message : Test suite Path  is null");
      return "success";
    }
    try {
      URL url = UtilURL.fromResource("seleniumXml.properties");
      if (props == null) {
        props = new Properties();
        initConfig(url);
      }
      SeleniumXml sel = new SeleniumXml();
      File testFile = new File(para.trim());
      if (testFile.exists()) {
        System.err.println(" Argument : " + para.trim());
        System.err.println(" Full absolute path of file : " + testFile.getAbsolutePath());
        System.err.println(" Full canonical path of file : " + testFile.getCanonicalPath());

        sel.testCaseDirectory = sel.getFileDirectory(testFile.getAbsolutePath());
        System.err.println(" testCaseDirectory: " + sel.testCaseDirectory);
        sel.runTest(testFile.getAbsolutePath());
      } else {
        System.err.println("Test File is not exist :" + para.trim());
      }
    } catch (JDOMException jdome) {
      System.out.println(jdome.getMessage());
    } catch (IOException ioe) {
      System.out.println("Error message : " + ioe.getMessage());
    } finally {
      return "success";
    }
  }