Permalink
Browse files

Initial Commit

  • Loading branch information...
Pranav Verma
Pranav Verma committed Aug 21, 2012
0 parents commit 13e4597ef430704fac3bc8312027604bfd75859a
Showing with 11,842 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +7 −0 .npmignore
  3. +75 −0 README.md
  4. +141 −0 arrow_selenium/selenium.js
  5. +29 −0 arrow_server/ghostdriverlauncher.js
  6. +588 −0 arrow_server/server.js
  7. +27 −0 config/config.js
  8. +34 −0 config/descriptor-schema.json
  9. +20 −0 config/dimensions.json
  10. +19 −0 config/qunit-config.js
  11. +1 −0 ghostdriver
  12. +161 −0 index.js
  13. BIN lib/.DS_Store
  14. +327 −0 lib/client/driver.html
  15. +107 −0 lib/client/qunit-runner.js
  16. +15 −0 lib/client/qunit-seed.js
  17. +13 −0 lib/client/qunitHost.html
  18. +14 −0 lib/client/testHost.html
  19. +27 −0 lib/client/yuitest-console.js
  20. +35 −0 lib/client/yuitest-reporter.js
  21. +143 −0 lib/client/yuitest-runner.js
  22. +142 −0 lib/client/yuitest-seed.js
  23. +17 −0 lib/common/yui-arrow.js
  24. +145 −0 lib/controller/default.js
  25. +79 −0 lib/controller/locator.js
  26. +128 −0 lib/driver/node.js
  27. +478 −0 lib/driver/selenium.js
  28. +92 −0 lib/interface/arrow.js
  29. +31 −0 lib/interface/controller.js
  30. +124 −0 lib/interface/driver.js
  31. +352 −0 lib/session/sessionfactory.js
  32. +101 −0 lib/session/testsession.js
  33. +62 −0 lib/session/wdsession.js
  34. +192 −0 lib/util/arrowrecursive.js
  35. +157 −0 lib/util/arrowsetup.js
  36. +35 −0 lib/util/capabilitymanager.js
  37. +73 −0 lib/util/dataprovider.js
  38. +84 −0 lib/util/libmanager.js
  39. +54 −0 lib/util/properties.js
  40. +240 −0 lib/util/reportmanager.js
  41. +70 −0 lib/util/reportstack.js
  42. +4,375 −0 lib/util/webdriver.js
  43. +470 −0 lib/util/ycb.js
  44. +87 −0 nodejs/node.js
  45. +44 −0 package.json
  46. +120 −0 tests/unit/lib/controller/default-tests.js
  47. +68 −0 tests/unit/lib/controller/locator-tests.js
  48. +107 −0 tests/unit/lib/driver/node-tests.js
  49. +297 −0 tests/unit/lib/driver/selenium-tests.js
  50. +67 −0 tests/unit/lib/interface/arrow-tests.js
  51. +279 −0 tests/unit/lib/session/sessionfactory-tests.js
  52. +28 −0 tests/unit/lib/session/testdata/config.js
  53. +36 −0 tests/unit/lib/session/testdata/test-func.js
  54. +78 −0 tests/unit/lib/session/testdata/test-lib.js
  55. +72 −0 tests/unit/lib/session/testdata/testMock.html
  56. +71 −0 tests/unit/lib/session/testdata/test_descriptor.json
  57. +129 −0 tests/unit/lib/session/testsession-tests.js
  58. +117 −0 tests/unit/lib/session/wdsession-tests.js
  59. +1 −0 tests/unit/lib/util/badlibs/jsFileBadExtension
  60. +5 −0 tests/unit/lib/util/badlibs/nonJsFileGoodExtension.js
  61. +17 −0 tests/unit/lib/util/capabilities.json
  62. +39 −0 tests/unit/lib/util/capabilitymanager-tests.js
  63. +15 −0 tests/unit/lib/util/config/configoverride.js
  64. +29 −0 tests/unit/lib/util/config/defaultconfig.js
  65. +34 −0 tests/unit/lib/util/config/descriptor-schema.json
  66. +102 −0 tests/unit/lib/util/dataprovider-tests.js
  67. +20 −0 tests/unit/lib/util/dimensions.json
  68. +80 −0 tests/unit/lib/util/libmanager-tests.js
  69. +84 −0 tests/unit/lib/util/properties-tests.js
  70. +38 −0 tests/unit/lib/util/reportmanager-tests.js
  71. +98 −0 tests/unit/lib/util/reportstack-tests.js
  72. +36 −0 tests/unit/lib/util/testDescriptor.json
  73. +17 −0 tests/unit/stub/arrow.js
  74. +18 −0 tests/unit/stub/controller.js
  75. +38 −0 tests/unit/stub/driver.js
  76. +50 −0 tests/unit/stub/process.js
  77. +89 −0 tests/unit/stub/seleniumserver.js
  78. +144 −0 tests/unit/stub/webdriver.js
@@ -0,0 +1,4 @@
+*.swp
+.svn
+./node_modules
+./package.json.pl
@@ -0,0 +1,7 @@
+.lock-wscript
+.svn/
+.hg/
+.git/
+CVS/
+.DS_Store
+package.json.pl
@@ -0,0 +1,75 @@
+
+#Arrow
+
+
+
+##Overview
+
+Arrow is a test framework designed to promote test-driven JavaScript development. Arrow provides a consistent test creation and execution environment for both Developers and Quality Engineers.
+
+Arrow aims to completely remove the line between development’s Unit tests, and Functional and Integration tests by providing a uniform way to create and execute both.
+
+Arrow itself is a thin, extensible layer that marries JavaScript, NodeJS, PhantomJS and Selenium. Arrow allows you to write tests using YUI-Test and execute those tests using NodeJS, PhantomJS or Selenium. Additionally, Arrow provides a rich mechanism for building, organizing and executing test and test scenarios.
+
+
+##Options
+
+
+**--help** display this help page <br>
+**--version** display installed arrow version<br>
+**--lib** comma separated list of js files needed by the test<br>
+**--page** path to the mock or production html page, for example: http://www.yahoo.com or mock.html<br>
+**--driver** selenium|phantomjs|browser. (default: phantomjs)<br>
+**--browser** firefox|chrome|opera|reuse. Specify browser version with a hypen, ex.: firefox-4.0 or opera-11.0 (default: firefox)<br>
+**--controller** a custom controller javascript file<br>
+**--reuseSession** true/false. Specifies whether to run tests in existing sessions managed by selenium. Visit http://selenuim_host/wd/hub to setup sessions (default: false)<br>
+**--report** true/false. Creates report files in junit and json format, and also prints a consolidated test report summary on console<br>
+**--testName** comma separated list of test names defined in test descriptor. all other tests will be ignored<br>
+**--group** comma separated list of groups defined in test descriptor, all other groups will be ignored<br>
+**--logLevel** DEBUG|INFO|WARN|ERROR|FATAL (default: INFO)<br>
+**--dimension** a custom dimension file for defining ycb contexts<br>
+**--context** name of ycb context<br>
+
+
+
+##Examples
+
+Below are some examples to help you get started.
+
+###Unit test:
+arrow --lib=../src/greeter.js test-unit.js
+
+###Unit test with a mock page:
+arrow --page=testMock.html --lib=./test-lib.js test-unit.js
+
+###Unit test with selenium:
+arrow --page=testMock.html --lib=./test-lib.js --driver=selenium test-unit.js
+
+###Integration test:
+arrow --page=http://www.hostname.com/testpage --lib=./test-lib.js test-int.js
+
+###Integration test:
+arrow --page=http://www.hostname.com/testpage --lib=./test-lib.js --driver=selenium test-int.js
+
+###Custom controller:
+arrow --controller=custom-controller.js --driver=selenium
+
+
+##Arrow Dependencies
+
+**glob** https://github.com/isaacs/node-glob<br>
+**mockery** https://github.com/nathanmacinnes/Mockery<br>
+**nopt** https://github.com/isaacs/nopt<br>
+**colors** https://github.com/Marak/colors.js<br>
+**express** https://github.com/visionmedia/express<br>
+**yui** http://github.com/yui/yui3<br>
+**JSV** http://github.com/garycourt/JSV<br>
+**log4js** https://github.com/nomiddlename/log4js-node<br>
+**clone** https://github.com/pvorb/node-clone<br>
+**useragent** https://github.com/3rd-Eden/useragent<br>
+**ytestrunner** https://github.com/gotwarlost/ytestrunner<br>
+
+Apart from above mentioned npm modules, Arrow also relies on these two projects
+
+**selenium** https://code.google.com/p/selenium/<br>
+**ghostdriver** https://github.com/detro/ghostdriver
@@ -0,0 +1,141 @@
+#!/usr/bin/env node
+
+/*jslint forin:true sub:true anon:true, sloppy:true, stupid:true nomen:true, node:true continue:true*/
+
+/*
+* Copyright (c) 2012, Yahoo! Inc. All rights reserved.
+* Copyrights licensed under the New BSD License.
+* See the accompanying LICENSE file for terms.
+*/
+
+var fs = require("fs");
+var nopt = require("nopt");
+var log4js = require("log4js");
+
+var Properties = require("../lib/util/properties");
+var ArrowSetup = require('../lib/util/arrowsetup');
+var WdAppClass = require('../lib/util/webdriver');
+var WdSession = require("../lib/session/wdsession");
+
+//getting command line args
+var argv = nopt();
+
+// singleton app to interact with wd sessions
+var wdApp = new WdAppClass();
+
+//setup config
+var prop = new Properties(__dirname + "/../config/config.js", argv.config, argv);
+var config = prop.getAll();
+//console.log(config);
+var logger = log4js.getLogger("selenium");
+
+function listSessions(error, next, arrSessions) {
+ var sessionCaps = [],
+ sessionCount = 0,
+ i,
+ sessionId,
+ webdriver;
+
+ if (0 === arrSessions.length) {
+ next(sessionCaps);
+ }
+
+ function onSessionCap(val) {
+ sessionCaps[val.capabilities.browserName] = val;
+ sessionCount += 1;
+ if (sessionCount === arrSessions.length) {
+ next(sessionCaps);
+ }
+ }
+
+ for (i = 0; i < arrSessions.length; i += 1) {
+ sessionId = arrSessions[i];
+ webdriver = new wdApp.Builder().
+ usingServer(config["seleniumHost"]).
+ usingSession(sessionId).
+ build();
+ webdriver.session_.then(onSessionCap);
+ }
+}
+
+function describeSession(sessionCap) {
+ console.log(sessionCap);
+}
+
+function describeSessions(sessionCaps) {
+ console.log(sessionCaps);
+}
+
+function openBrowser(sessionCaps) {
+ var browsers = argv.open,
+ browserList = browsers.split(","),
+ webdriver,
+ browser,
+ i,
+ val;
+ for (i = 0; i < browserList.length; i += 1) {
+ browser = browserList[i];
+ if (0 === browser.length) { continue; }
+
+ logger.info("Opening browser: " + browser);
+ if (sessionCaps.hasOwnProperty(browser)) {
+ logger.info("Already open, ignored");
+ continue;
+ }
+
+ webdriver = new wdApp.Builder().
+ usingServer(config["seleniumHost"]).
+ withCapabilities({
+ "browserName": browser,
+ "version": "",
+ "platform": "ANY",
+ "javascriptEnabled": true
+ }).build();
+ webdriver.session_.then(describeSession);
+ }
+}
+
+function closeBrowsers(sessionCaps) {
+ var browser,
+ cap,
+ webdriver;
+ for (browser in sessionCaps) {
+ logger.info("Closing browser: " + browser);
+
+ cap = sessionCaps[browser];
+ webdriver = new wdApp.Builder().
+ usingServer(config["seleniumHost"]).
+ usingSession(cap.id).
+ build();
+ webdriver.quit();
+ }
+}
+
+function listHelp() {
+ console.info("\nCommandline Options :" + "\n" +
+ "--list : Lists all selenium browser sessions" + "\n" +
+ "--open : Comma seperated list of browsers to launch" + "\n" +
+ "--close : Close all selenium controller browser sessions" + "\n"
+ );
+}
+
+
+var arrowSetup = new ArrowSetup(config, argv);
+arrowSetup.setuplog4js();
+arrowSetup.setupSeleniumHost();
+logger.info("Selenium host: " + config["seleniumHost"]);
+
+var hub = new WdSession(config);
+
+if (argv.list || argv.ls) {
+ hub.getSessions(describeSessions, listSessions, false);
+} else if (argv.open) {
+ hub.getSessions(openBrowser, listSessions, true);
+} else if (argv.close) {
+ hub.getSessions(closeBrowsers, listSessions, true);
+} else if (argv.help) {
+ listHelp();
+} else {
+ listHelp();
+}
+
@@ -0,0 +1,29 @@
+#!/usr/bin/env node
+
+/*jslint forin:true sub:true anon:true sloppy:true stupid:true nomen:true node:true continue:true*/
+
+var childProcess = require("child_process");
+var fs = require("fs");
+var ghostPort = process.argv[2];
+var arrowHost = process.argv[3];
+
+//console.log(ghostPort + ":" + arrowHost );
+
+process.chdir(__dirname + "/../ghostdriver/src");
+var child = childProcess.spawn("phantomjs", ["main.js", ghostPort]);
+var initPhantom = false;
+
+child.stdout.on("data", function (data) {
+ var pjUrl;
+ console.log(data.toString());
+ if (!initPhantom) {
+ //console.log("Writing arrow_phantom_server.status");
+ pjUrl = "http://" + arrowHost + ":" + ghostPort;
+ fs.writeFileSync("/tmp/arrow_phantom_server.status", pjUrl);
+ initPhantom = true;
+ }
+});
+
+child.stderr.on("data", function (data) {
+ console.error(data.toString());
+});
Oops, something went wrong.

0 comments on commit 13e4597

Please sign in to comment.