Skip to content

Commit

Permalink
update the cookbook to include CRT part
Browse files Browse the repository at this point in the history
  • Loading branch information
aiqin committed Jan 7, 2013
1 parent 70fc608 commit b83ed92
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 14 deletions.
Binary file modified docs/arrow_cookbook/DetailedArchitectureDiagram.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion docs/arrow_cookbook/README.rst
Expand Up @@ -25,7 +25,7 @@ Options
display installed arrow version
--lib comma separated list of js files needed by the test
--page path to the mock or production html page, for example: http://www.yahoo.com or mock.html
--driver selenium|phantomjs|browser. (default: phantomjs)
--driver selenium|phantomjs|browser|crt. (default: phantomjs)
--browser firefox|chrome|opera|reuse. Specify browser version with a hypen, ex.: firefox-4.0 or opera-11.0 (default: firefox)
--controller a custom controller javascript file
--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)
Expand All @@ -35,6 +35,7 @@ Options
--logLevel DEBUG|INFO|WARN|ERROR|FATAL (default: INFO)
--dimension a custom dimension file for defining ycb contexts
--context name of ycb context
--crtTestServer override crtTestServer host url (example: --crtTestServer=http://host.com:port/shanghai), default is http://localhost:9000/shanghai.


Examples
Expand All @@ -59,6 +60,8 @@ Examples
| Custom controller:
| arrow --controller=custom-controller.js --driver=selenium
| Function test with crt driver:
arrow crt_descriptor.json --driver=crt
See Also
========
Expand Down
23 changes: 22 additions & 1 deletion docs/arrow_cookbook/arrow_FAQs.rst
Expand Up @@ -109,6 +109,14 @@ You need to start Arrow server like this

Because arrow_server needs to KEEP running, start it on a different command prompt than the one you are using for testing

Error: No crt sessions found, cannot run tests
---------------------------------------------------
Before run the CRT app test, you need regist the app to the crt test server. i.e the App is launched on the simulator or real device, and the web view has been injected.

Solution
========
Manually or automatically launch your CRT app before testing.

How do I point Arrow to a Specific Selenium Server
--------------------------------------------------

Expand All @@ -128,6 +136,19 @@ You can tell Arrow to point to a specific Selenium Host in two ways

seleniumHost=http://url.to.server:port/wd/hub

How do I point Arrow to a Specific CRT Test Server
--------------------------------------------------
There may be situatios where the CRT Test Server may not be running on the localhost.

Solution
========
You can tell Arrow to point to a specific CRT Test Server: Use the **--crtTestServer** parameter in your command

**Note** you need to include the **FULL** path to crt Test Server like this:

::
crtTestServer=http://url.to.server:port/shanghai

[ERROR] ArrowServer - <Buffer 65 78 65
--------------------------------------

Expand All @@ -145,7 +166,7 @@ Make sure you have `installed PhantomJS <./arrow_getting_started.html#mac-instal
How can I use the Locator Controller to Login?
----------------------------------------------

Built-in, Arrow comes with two controllers, default and `locator <./arrow_in-depth.html#the-locator-controller>`_
Built-in, Arrow comes with three controllers, default, crt and `locator <./arrow_in-depth.html#the-locator-controller>`_

Solution
========
Expand Down
4 changes: 2 additions & 2 deletions docs/arrow_cookbook/arrow_extending.rst
Expand Up @@ -7,11 +7,11 @@ Extending Controllers

Controllers are a very important part of Arrow. As described in the `architecture, <./arrow_intro.html#arrow-internals>`_ *controllers* are a way to *control* when and where your test will execute. By default, **Arrow** assumes you want to execute your test against the *page* or *HTTP End-Point* given in the **--page=** parameter.

Additionally, Arrow provides the concept of `complex scenarios, <./arrow_in-depth.html#complex-test-scenarios>`_ you can create a *scenario* using a combination of the *default* and the `locator controller. <./arrow_in-depth.html#the-locator-controller>`_
Additionally, Arrow provides the concept of `complex scenarios, <./arrow_in-depth.html#complex-test-scenarios>`_ you can create a *scenario* using a combination of the *default*, *crt* and the `locator controller. <./arrow_in-depth.html#the-locator-controller>`_

However, there may still be the case where Arrow's built-in controllers are not sufficient for your needs. In this case, a user can create their own **custom controllers** to satisfy their needs.

All controllers, including *default* and *locator* extend from the same **controller** interface. The **controller** interface provides you the following methods:
All controllers, including *default* , *crt* and *locator* extend from the same **controller** interface. The **controller** interface provides you the following methods:

* setup
* execute
Expand Down
35 changes: 35 additions & 0 deletions docs/arrow_cookbook/arrow_getting_started.rst
Expand Up @@ -151,6 +151,28 @@ To start Selenium Server using chromedriver and default Firefox profile use

java -Dwebdriver.chrome.driver=./chromedriver -Dwebdriver.firefox.profile=default -jar selenium-server-standalone-2.xx.0.jar

CRT Test Server
---------------

Arrow uses CRT Test Server to execute all CRT app tests. CRT test server should run on a machine which can be accessed by arrow and the CRT app.

Start CRT Server
================

To start CRT Test Server you simply need to do the following:
1. Download the CRT Test Server package:

::

npm install shanghai-server

2. Start the server

::

shanghai-server --host=<your ip address>

Note CRT Test Server is **NOT** required for Arrow to work. If you don't test the CRT app, shanghai server is not needed.

.. _Verification:

Expand Down Expand Up @@ -192,6 +214,7 @@ Check Arrow Help
--dimensions : (optional) a custom dimension file for defining ycb contexts
--context : (optional) name of ycb context
--seleniumHost : (optional) override selenium host url (example: --seleniumHost=http://host.com:port/wd/hub)
--crtTestServer : (optional) override crtTestServer host url (example: --crtTestServer=http://host.com:port/shanghai), default is http://localhost:9000/shanghai
--capabilities : (optional) the name of a json file containing webdriver capabilities required by your project

EXAMPLES :
Expand All @@ -207,6 +230,9 @@ Check Arrow Help
arrow test-int.js --page=http://www.hostname.com/testpage --lib=./test-lib.js --driver=selenium
Custom controller:
arrow --controller=custom-controller.js --driver=selenium
Function test with crt driver:
arrow crt_descriptor.json --driver=crt


Check Arrow version
===================
Expand Down Expand Up @@ -244,6 +270,15 @@ Though Selenium Server is NOT required, if you chose to run it, you can confirm

.. _Creating a test:

Confirm CRT Test Server is Running
==================================

Though CRT Test Server is NOT required, if you chose to run it, you can confirm it's running successfully like this:

1. From a browser, go to: http://host.or.url:port or http://localhost:9000
2. you should open a webpage


Creating a test
---------------

Expand Down
10 changes: 8 additions & 2 deletions docs/arrow_cookbook/arrow_in-depth.rst
Expand Up @@ -351,6 +351,7 @@ The standard arrow config file looks like this

// User default config
config.seleniumHost = "";
config.crtTestServer = "http://localhost:9000/shanghai";
//example: config.seleniumHost = "http://gridhost:port/wd/hub";
config.context = "";
config.defaultAppHost = "";
Expand All @@ -362,6 +363,7 @@ The standard arrow config file looks like this
config.arrowModuleRoot = global.appRoot + "/";
config.dimensions = config.arrowModuleRoot + "config/dimensions.json";
config.defaultTestHost = config.arrowModuleRoot + "lib/client/testHost.html";
config.defaultCrtTestHost = config.arrowModuleRoot + "lib/client/crtTestHost.html";
config.defaultAppSeed = "http://yui.yahooapis.com/3.6.0/build/yui/yui-min.js";
config.testSeed = config.arrowModuleRoot + "lib/client/yuitest-seed.js";
config.testRunner = config.arrowModuleRoot + "lib/client/yuitest-runner.js";
Expand Down Expand Up @@ -404,7 +406,7 @@ You can also **completely** override all configuration values by placing a confi
Complex Test Scenarios
----------------------

There are situations where the default arrow controller will not allow you to create the type of test scenario you require. If you recall, the default arrow controller assumes the page you load is the page under test. To solve this you can use a different arrow controller called *locator*. The *locator* controller allows you to navigate to the page under test by allowing you to perform actions such as clicking and typing.
There are situations where the default arrow controller will not allow you to create the type of test scenario you require. If you recall, the default arrow controller assumes the page you load is the page under test. To solve this you can use a different arrow controller called *locator*. The *locator* controller allows you to navigate to the page under test by allowing you to perform actions such as clicking and typing. Further more, default and locator controller only let you test the web application, not CRT app. You can use *crt* controller to test the CRT App.

The controller samples can be found `here.

Expand Down Expand Up @@ -505,6 +507,10 @@ For example, you could have the following in your test descriptor
}
}

The Crt Controller
==================

The Crt controller is exact the same as locator controller except Crt controller is used to test the CRT app on the mobile device. And the baseUrl is the CRT app index page url, not the browser's web url.

Re-Using Browser Sessions
-------------------------
Expand Down Expand Up @@ -642,4 +648,4 @@ report.json sample
"ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0",
"testName":"Test YHOO Ticker"
}
]
]
4 changes: 2 additions & 2 deletions docs/arrow_cookbook/arrow_intro.rst
Expand Up @@ -15,7 +15,7 @@ Arrow's design is based on the idea that test purpose should not dictate how tes
What can I do with Arrow?
-------------------------

The answer is simple, anything you can do with JS and NodeJS or Selenium, you can do with Arrow. In addition to Unit, Functional and Integration tests, you can also test WebServices using NodeJS
The answer is simple, anything you can do with JS and NodeJS or Selenium, you can do with Arrow. In addition to Unit, Functional and Integration tests, you can also test WebServices using NodeJS and you can test CRT app with arrow too.

Arrow Internals
---------------
Expand All @@ -25,7 +25,7 @@ Arrow's architecture is very simple. It is made up of 5 main components
Core components:

* Test Session: Provides the mechanism for injecting tests onto a page.
* Driver: In Arrow's terminology, this is what determines the driver of your tests. Which mechanism do you want injecting your tests. NodeJS, PhantomJS and Selenium are fully supported.
* Driver: In Arrow's terminology, this is what determines the driver of your tests. Which mechanism do you want injecting your tests. NodeJS, PhantomJS, CRT and Selenium are fully supported.
* Arrow Server: Arrow sever provides two very important functionalities. Firstly, it's a simple file server used to **serve** local mock pages when executing your tests using Selenium. Secondly, it is a reverse-proxy with a Web Driver implementation. This is used as a way to execute tests against browsers and devices not supported by Selenium. With Arrow Server running, **ANY** device can **register** itself with a given instance of Arrow Server, and said device and then be used as a test executor.

User-facing Components:
Expand Down
2 changes: 1 addition & 1 deletion docs/arrow_cookbook/arrow_tutorial.rst
Expand Up @@ -190,4 +190,4 @@ Similarly, you can run func tests (test-func.js) against the HTTP End-Point like
Conclusion
==========

As you can see, Arrow allows you to execute all types of tests (unit, functional and integration) using the same methodology. Unlike other frameworks, it does not dictate to you how to execute different tests, as far as Arrow is concerned, tests are just tests.
As you can see, Arrow allows you to execute all types of tests (unit, functional and integration) using the same methodology. Unlike other frameworks, it does not dictate to you how to execute different tests, as far as Arrow is concerned, tests are just tests.
8 changes: 7 additions & 1 deletion docs/arrow_cookbook/arrow_usage.rst
Expand Up @@ -10,7 +10,7 @@ Arrow Usage
--version display installed arrow version
--lib comma separated list of js files needed by the test
--page (optional) path to the mock or production html page, for example: http://www.yahoo.com or mock.html
--driver (optional) selenium|phantomjs|browser, default: phantomjs
--driver (optional) selenium|phantomjs|browser|crt, default: phantomjs
--browser (optional) firefox|chrome|opera|reuse, default: firefox
--controller (optional) a custom controller javascript file
--reuseSession (optional) true, Used to run tests in existing sessions managed by selenium. Visit http://selenuim_host/wd/hub to setup sessions.
Expand All @@ -20,6 +20,8 @@ Arrow Usage
--logLevel (optional) DEBUG|INFO|WARN|ERROR|FATAL, default: INFO
--dimension (optional) a custom dimension file for defining ycb contexts
--context (optional) name of ycb context
--crtTestServer (optional) override crtTestServer host url (example: --crtTestServer=http://host.com:port/shanghai), default is http://localhost:9000/shanghai



.. _Examples:
Expand All @@ -43,3 +45,7 @@ Arrow Usage

Custom controller:
arrow --controller=custom-controller.js --driver=selenium

Function test with crt driver:
arrow crt_descriptor.json --driver=crt

6 changes: 3 additions & 3 deletions index.js
Expand Up @@ -79,7 +79,7 @@ function showHelp() {
" --lib : a comma seperated list of js files needed by the test" + "\n\n" +
" --page : (optional) path to the mock or production html page" + "\n" +
" example: http://www.yahoo.com or mock.html" + "\n\n" +
" --driver : (optional) one of selenium|nodejs. (default: selenium)" + "\n\n" +
" --driver : (optional) one of selenium|nodejs|crt. (default: selenium)" + "\n\n" +
" --browser : (optional) a comma seperated list of browser names, optionally with a hypenated version number.\n" +
" Example : 'firefox-12.0,chrome-10.0' or 'firefox,chrome' or 'firefox'. (default: firefox)" + "\n\n" +
" --parallel : (optional) test thread count. Determines how many tests to run in parallel for current session. (default: 1)\n" +
Expand All @@ -95,7 +95,7 @@ function showHelp() {
" --dimensions : (optional) a custom dimension file for defining ycb contexts" + "\n\n" +
" --context : (optional) name of ycb context" + "\n\n" +
" --seleniumHost : (optional) override selenium host url (example: --seleniumHost=http://host.com:port/wd/hub)" + "\n\n" +
" --crtTestServer : (optional) override crtTestServer host url (example: --crtTestServer=http://host.com:port/shanghai), the default is http://localhost:9000/shanghai" + "\n\n" +
" --crtTestServer : (optional) override crtTestServer host url (example: --crtTestServer=http://host.com:port/shanghai), default is http://localhost:9000/shanghai" + "\n\n" +
" --capabilities : (optional) the name of a json file containing webdriver capabilities required by your project" +
" --startProxyServer : (optional) true/false. Starts a proxy server for all intercepting all selenium browser calls" +
" --routerProxyConfig : (optional) filePath. Expects a Json file, allows users to modify host and headers for all calls being made by browser. Also supports recording of select url calls." + "\n" +
Expand Down Expand Up @@ -139,7 +139,7 @@ function showHelp() {
" arrow test-int.js --page=http://www.hostname.com/testpage --lib=./test-lib.js --driver=selenium" + "\n\n" +
" Custom controller: " + "\n" +
" arrow --controller=custom-controller.js --driver=selenium" + "\n\n" +
" Function test with crt web driver: \n" +
" Function test with crt driver: \n" +
" arrow crt_descriptor.json --driver=crt" + "\n\n");
}

Expand Down
2 changes: 1 addition & 1 deletion lib/session/sessionfactory.js
Expand Up @@ -268,7 +268,7 @@ if(self.args.driver!=="crt"){//change for crt driver: keep current process for s
controller.getSessions(function(sessions) {
if (sessions.length === 0) {
controller.close();
self.logger.info("No shanghai sessions found, cannot run tests!");
self.logger.error("No crt sessions found, cannot run tests!");
} else {
crtSessions = sessions;
self.logger.debug("the sessions are:" + util.inspect(crtSessions));
Expand Down

0 comments on commit b83ed92

Please sign in to comment.