Skip to content

Commit

Permalink
Add information in debugging in k3po.js, added some extra logging in …
Browse files Browse the repository at this point in the history
…the browser for when debugging was enabled
  • Loading branch information
David Witherspoon committed Jan 13, 2016
1 parent 2c51000 commit 170693c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ module.exports = function (grunt) {
ui: 'mocha-k3po',
require: 'lib/testFrameworks/mocha-k3po.js',
captureFile: "build/testMochaK3po.txt",
// timeout: 5000,
browser: {
// debug: true,
desiredCapabilities: {
browserName: 'firefox'
}
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,19 @@ Configuration via Grunt
1. `npm install`
1. `grunt`
### Debugging the browser
By default the browser closes after the test, in case of test failures you can pass the debug flag to the browser
configuration as shown to keep it open. This allows access to the browser javascript console.
```JavaScript
browser: {
desiredCapabilities: {
browserName: 'firefox'
},
debug: true
}

```
6 changes: 3 additions & 3 deletions lib/browser/BrowserRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ BrowserRunner.prototype.loadOrigin = function () {
_this._browser.url(this._origin);
}

return _this._browser.execute(RemoteScriptRunner).execute(function (resources) {
k3po = new RemoteScriptRunner(resources);
}, _this._resources).then();
return _this._browser.execute(RemoteScriptRunner).execute(function (resources, debug) {
k3po = new RemoteScriptRunner(resources, debug);
}, _this._resources, _this._debug).then();
};

BrowserRunner.prototype.getExceptions = function () {
Expand Down
12 changes: 10 additions & 2 deletions lib/browser/RemoteScriptRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ var window;
*/
module.exports = function () {

RemoteScriptRunner = function RemoteScriptRunner(resources) {
RemoteScriptRunner = function RemoteScriptRunner(resources, debug) {
this._state = "INITIAL";
this._cmdQueue = [];
this._eventListenerMap = [];
this._eventAlreadyFiredEventMap = [];
this._debug = debug;
for (var i = 0; i < resources.length; i++) {
this.loadScript(resources[i]);
}
Expand Down Expand Up @@ -138,7 +139,11 @@ module.exports = function () {

RemoteScriptRunner.prototype.nextCommand = function () {
if (this._cmdQueue.length > 0) {
return this._cmdQueue.shift();
var command = this._cmdQueue.shift();
if(this._debug) {
console.log("RemoteScriptRunner received command: " + command);
}
return command;
}
return null;
};
Expand All @@ -153,6 +158,9 @@ module.exports = function () {
var arg = null;
var type = event.type;

if(this._debug) {
console.log("RemoteScriptRunner fired event: " + type);
}
switch (type) {
case "NOTIFIED":
arg = event.barrier;
Expand Down
2 changes: 1 addition & 1 deletion test/testFrameworks/mocha-k3po_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ describe('WsClient', function () {
ws.onmessage = function (event) {
chai.assert.equal(event.data, echoText);
ws.close();
done();
};

ws.onclose = ws.onerror = function () {
done();
};
});

Expand Down

0 comments on commit 170693c

Please sign in to comment.