public static void main(String args[]) { try { SeleniumHtmlClient client = new SeleniumHtmlClient(); String testFile = null; String testSuite = null; String resultsFilename = null; for (int i = 0; i < args.length; i++) { if (args[i].equals("--host")) { i++; if (i < args.length) { client.setHost(args[i]); } else { throw new BadUsageException("--host must be followed by a hostname"); } } else if (args[i].equals("--port")) { i++; if (i < args.length) { client.setPort(Integer.parseInt(args[i])); } else { throw new BadUsageException("--port must be followed by a port number"); } } else if (args[i].equals("--browser")) { i++; if (i < args.length) { client.setBrowser(args[i]); } else { throw new BadUsageException("--browser must be followed by a browser spec"); } } else if (args[i].equals("--out")) { i++; if (i < args.length) { resultsFilename = args[i]; } else { throw new BadUsageException("--out must be followed by a filename"); } /* } else if (args[i].equals("--outdir")) { i++; if (i < args.length) { client.setResultsDir(new File(args[i])); } else { throw new BadUsageException("--outdir must be followed by a path"); } */ } else if (args[i].equals("--baseurl")) { i++; if (i < args.length) { client.setBaseUrl(args[i]); } else { throw new BadUsageException("--baseurl must be followed by a URL"); } } else if (args[i].equals("--test")) { i++; if (i < args.length) { if (testFile == null) { testFile = args[i]; } else { throw new BadUsageException("only one test file permitted"); } } else { throw new BadUsageException("--test must be followed by a test filepath"); } } else if (args[i].equals("--testsuite")) { i++; if (i < args.length) { testSuite = args[i]; } else { throw new BadUsageException("--testsuite must be followed by a testsuite filepath"); } } else if (args[i].equals("--verbose") || args[i].equals("-v")) { client.setVerbose(true); } else if (args[i].equals("--help") || args[i].equals("-h")) { printUsage(); System.exit(0); } else { throw new BadUsageException("Unknown parameter " + args[i]); } } if (testFile == null && testSuite == null) { throw new BadUsageException("No test or testsuite file specified"); } else if (testFile != null && testSuite != null) { throw new BadUsageException("A test and testsuite file cannot both be specified"); } Writer resultsWriter = null; if (resultsFilename != null) { resultsWriter = new FileWriter(resultsFilename); } else /* if (client.resultsDir == null) */ { resultsWriter = new OutputStreamWriter(System.out); } client.setResultsWriter(resultsWriter); if (testFile != null) { client.runTest(testFile); } else { client.runSuite(testSuite); } if (resultsWriter != null) resultsWriter.close(); } catch (BadUsageException e) { System.err.println("Error: " + e.getMessage()); System.err.println(); printUsage(); System.exit(1); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }