|
| 1 | +TestCafe RPC |
| 2 | +====== |
| 3 | +RPC library for the [TestCafé](http://testcafe.devexpress.com/). It allows you to create a single TestCafé instance and then interact with it programmatically from any machine in your network. |
| 4 | + |
| 5 | + |
| 6 | +Install |
| 7 | +------- |
| 8 | +``` |
| 9 | +$ npm install testcafe-rpc |
| 10 | +``` |
| 11 | + |
| 12 | +Running a server |
| 13 | +------------- |
| 14 | +```js |
| 15 | +var TestCafeRemote = require('testcafe-rpc'); |
| 16 | + |
| 17 | +//Options for TestCafé instance |
| 18 | +var opt = { |
| 19 | + controlPanelPort: 1337, |
| 20 | + servicePort: 1338, |
| 21 | + testsDir: 'YOUR_TESTS_DIR', |
| 22 | + browsers: { |
| 23 | + 'Mozilla Firefox': { |
| 24 | + path: "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe", |
| 25 | + icon: "ff", |
| 26 | + cmd: "-new-window" |
| 27 | + } |
| 28 | + } |
| 29 | + }, |
| 30 | + rpcPort = 1339; |
| 31 | + |
| 32 | +//Create TestCafé server instance with given options which can be accessed via RPC on port 1339. |
| 33 | +var testCafeServer = new TestCafeRemote.Server(opt, rpcPort); |
| 34 | + |
| 35 | +//Returned object exposes standard TestCafé API, so you can use it as a regular TestCafé instance. |
| 36 | +testCafeServer.runTests({ browsers: testCafeServer.listAvailableBrowsers() }, function (errors, taskUid, workers) { |
| 37 | + //do smthg... |
| 38 | +}); |
| 39 | +``` |
| 40 | + |
| 41 | +Running a client |
| 42 | +------------- |
| 43 | +```js |
| 44 | +var TestCafeRemote = require('testcafe-rpc'); |
| 45 | + |
| 46 | +var rpcHostname = 'myhostname', |
| 47 | + rpcPort = 1339; |
| 48 | + |
| 49 | +//Connect to the existent TestCafé server (if you running both client and server on the same machine |
| 50 | +//hostname-parameter can be ommited). |
| 51 | +var testCafeClient = new TestCafeRemote.Client(rpcPort, rpcHostname); |
| 52 | + |
| 53 | +//Client can be used as a regular TestCafé instance with exception that listAvailableBrowsers() and listConnectedWorkers() |
| 54 | +//are asynchronous methods. |
| 55 | +testCafeClient.listAvailableBrowsers(function(browsers) { |
| 56 | + testCafeClient.runTests({ browsers: browsers }, function (errors, taskUid, workers) { |
| 57 | + //do smthg... |
| 58 | + }); |
| 59 | +}); |
| 60 | +``` |
| 61 | +Need more help to get started? |
| 62 | +-------------- |
| 63 | +Visit TestCafé [Continuous integration guide](http://testcafe.devexpress.com/Documentation/Tutorial/Continuous_Integration) and [Continuous integration API reference](http://testcafe.devexpress.com/Documentation/ApiReference/Continuous_Integration_API_Reference). If you have any additional questions or suggestions don't hesitate to ask using [DevExpress Support Center](http://www.devexpress.com/Support/Center/Question/ChangeFilterSet/1?FavoritesOnly=False&MyItemsOnly=False&MyTeamItemsOnly=False&TechnologyName=Testing+Tools&PlatformName=AllPlatforms&ProductName=AllProducts&TicketType=All). |
| 64 | + |
| 65 | +License |
| 66 | +---------- |
| 67 | +Copyright (c) 2013 DevExpress (www.devexpress.com) |
| 68 | + |
| 69 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 70 | +of this software and associated documentation files (the "Software"), to deal |
| 71 | +in the Software without restriction, including without limitation the rights |
| 72 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 73 | +copies of the Software, and to permit persons to whom the Software is |
| 74 | +furnished to do so, subject to the following conditions: |
| 75 | + |
| 76 | +The above copyright notice and this permission notice shall be included in |
| 77 | +all copies or substantial portions of the Software. |
| 78 | + |
| 79 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 80 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 81 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 82 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 83 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 84 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 85 | +THE SOFTWARE. |
| 86 | + |
| 87 | + |
0 commit comments