2011-07-17 08:05:43 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
2010-10-18 21:02:18 +00:00
|
|
|
/**
|
|
|
|
|
* Shared DSL statements that are useful to all scenarios.
|
|
|
|
|
*/
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
|
2010-10-19 20:17:49 +00:00
|
|
|
/**
|
|
|
|
|
* Usage:
|
2011-06-03 22:22:43 +00:00
|
|
|
* pause() pauses until you call resume() in the console
|
2010-10-19 20:17:49 +00:00
|
|
|
*/
|
2011-06-03 22:22:43 +00:00
|
|
|
angular.scenario.dsl('pause', function() {
|
2010-10-19 20:17:49 +00:00
|
|
|
return function() {
|
2011-06-03 22:22:43 +00:00
|
|
|
return this.addFuture('pausing for you to resume', function(done) {
|
|
|
|
|
this.emit('InteractivePause', this.spec, this.step);
|
2010-10-19 20:17:49 +00:00
|
|
|
this.$window.resume = function() { done(); };
|
|
|
|
|
});
|
|
|
|
|
};
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
});
|
2010-10-18 21:02:18 +00:00
|
|
|
|
|
|
|
|
/**
|
2010-10-29 23:02:57 +00:00
|
|
|
* Usage:
|
2011-06-03 22:22:43 +00:00
|
|
|
* sleep(seconds) pauses the test for specified number of seconds
|
2010-10-29 23:02:57 +00:00
|
|
|
*/
|
2011-06-03 22:22:43 +00:00
|
|
|
angular.scenario.dsl('sleep', function() {
|
2010-10-29 23:02:57 +00:00
|
|
|
return function(time) {
|
2011-06-03 22:22:43 +00:00
|
|
|
return this.addFuture('sleep for ' + time + ' seconds', function(done) {
|
2010-10-29 23:02:57 +00:00
|
|
|
this.$window.setTimeout(function() { done(null, time * 1000); }, time * 1000);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Usage:
|
|
|
|
|
* browser().navigateTo(url) Loads the url into the frame
|
|
|
|
|
* browser().navigateTo(url, fn) where fn(url) is called and returns the URL to navigate to
|
2010-11-02 00:24:24 +00:00
|
|
|
* browser().reload() refresh the page (reload the same URL)
|
2011-10-24 22:22:34 +00:00
|
|
|
* browser().window.href() window.location.href
|
|
|
|
|
* browser().window.path() window.location.pathname
|
|
|
|
|
* browser().window.search() window.location.search
|
|
|
|
|
* browser().window.hash() window.location.hash without # prefix
|
2011-11-12 01:15:22 +00:00
|
|
|
* browser().location().url() see angular.module.ng.$location#url
|
|
|
|
|
* browser().location().path() see angular.module.ng.$location#path
|
|
|
|
|
* browser().location().search() see angular.module.ng.$location#search
|
|
|
|
|
* browser().location().hash() see angular.module.ng.$location#hash
|
2010-10-29 23:02:57 +00:00
|
|
|
*/
|
|
|
|
|
angular.scenario.dsl('browser', function() {
|
|
|
|
|
var chain = {};
|
|
|
|
|
|
|
|
|
|
chain.navigateTo = function(url, delegate) {
|
|
|
|
|
var application = this.application;
|
2010-11-01 23:51:15 +00:00
|
|
|
return this.addFuture("browser navigate to '" + url + "'", function(done) {
|
2010-10-29 23:02:57 +00:00
|
|
|
if (delegate) {
|
|
|
|
|
url = delegate.call(this, url);
|
|
|
|
|
}
|
|
|
|
|
application.navigateTo(url, function() {
|
|
|
|
|
done(null, url);
|
|
|
|
|
}, done);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2010-11-02 00:24:24 +00:00
|
|
|
chain.reload = function() {
|
|
|
|
|
var application = this.application;
|
|
|
|
|
return this.addFutureAction('browser reload', function($window, $document, done) {
|
|
|
|
|
var href = $window.location.href;
|
|
|
|
|
application.navigateTo(href, function() {
|
|
|
|
|
done(null, href);
|
|
|
|
|
}, done);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-24 22:22:34 +00:00
|
|
|
chain.window = function() {
|
2010-10-29 23:02:57 +00:00
|
|
|
var api = {};
|
|
|
|
|
|
|
|
|
|
api.href = function() {
|
2011-10-24 22:22:34 +00:00
|
|
|
return this.addFutureAction('window.location.href', function($window, $document, done) {
|
2010-10-29 23:02:57 +00:00
|
|
|
done(null, $window.location.href);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-24 22:22:34 +00:00
|
|
|
api.path = function() {
|
|
|
|
|
return this.addFutureAction('window.location.path', function($window, $document, done) {
|
|
|
|
|
done(null, $window.location.pathname);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
api.search = function() {
|
|
|
|
|
return this.addFutureAction('window.location.search', function($window, $document, done) {
|
|
|
|
|
done(null, $window.location.search);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2010-10-29 23:02:57 +00:00
|
|
|
api.hash = function() {
|
2011-10-24 22:22:34 +00:00
|
|
|
return this.addFutureAction('window.location.hash', function($window, $document, done) {
|
2010-10-29 23:02:57 +00:00
|
|
|
done(null, $window.location.hash.replace('#', ''));
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-24 22:22:34 +00:00
|
|
|
return api;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
chain.location = function() {
|
|
|
|
|
var api = {};
|
|
|
|
|
|
|
|
|
|
api.url = function() {
|
|
|
|
|
return this.addFutureAction('$location.url()', function($window, $document, done) {
|
2011-11-12 23:23:30 +00:00
|
|
|
done(null, $window.angular.injector('ng').get('$location').url());
|
2010-10-29 23:02:57 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-24 22:22:34 +00:00
|
|
|
api.path = function() {
|
|
|
|
|
return this.addFutureAction('$location.path()', function($window, $document, done) {
|
2011-11-12 23:23:30 +00:00
|
|
|
done(null, $window.angular.injector('ng').get('$location').path());
|
2010-10-29 23:02:57 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-24 22:22:34 +00:00
|
|
|
api.search = function() {
|
|
|
|
|
return this.addFutureAction('$location.search()', function($window, $document, done) {
|
2011-11-12 23:23:30 +00:00
|
|
|
done(null, $window.angular.injector('ng').get('$location').search());
|
2010-10-29 23:02:57 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-24 22:22:34 +00:00
|
|
|
api.hash = function() {
|
|
|
|
|
return this.addFutureAction('$location.hash()', function($window, $document, done) {
|
2011-11-12 23:23:30 +00:00
|
|
|
done(null, $window.angular.injector('ng').get('$location').hash());
|
2010-10-29 23:02:57 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return api;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return function(time) {
|
|
|
|
|
return chain;
|
|
|
|
|
};
|
2010-10-18 21:02:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Usage:
|
|
|
|
|
* expect(future).{matcher} where matcher is one of the matchers defined
|
|
|
|
|
* with angular.scenario.matcher
|
|
|
|
|
*
|
|
|
|
|
* ex. expect(binding("name")).toEqual("Elliott")
|
|
|
|
|
*/
|
|
|
|
|
angular.scenario.dsl('expect', function() {
|
|
|
|
|
var chain = angular.extend({}, angular.scenario.matcher);
|
|
|
|
|
|
|
|
|
|
chain.not = function() {
|
|
|
|
|
this.inverse = true;
|
|
|
|
|
return chain;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return function(future) {
|
|
|
|
|
this.future = future;
|
|
|
|
|
return chain;
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Usage:
|
2010-10-27 18:29:51 +00:00
|
|
|
* using(selector, label) scopes the next DSL element selection
|
2010-10-18 21:02:18 +00:00
|
|
|
*
|
|
|
|
|
* ex.
|
2010-10-27 18:29:51 +00:00
|
|
|
* using('#foo', "'Foo' text field").input('bar')
|
2010-10-18 21:02:18 +00:00
|
|
|
*/
|
|
|
|
|
angular.scenario.dsl('using', function() {
|
2010-10-27 18:29:51 +00:00
|
|
|
return function(selector, label) {
|
2010-11-01 23:51:15 +00:00
|
|
|
this.selector = _jQuery.trim((this.selector||'') + ' ' + selector);
|
2010-10-27 18:29:51 +00:00
|
|
|
if (angular.isString(label) && label.length) {
|
2010-11-01 23:51:15 +00:00
|
|
|
this.label = label + ' ( ' + this.selector + ' )';
|
2010-10-27 18:29:51 +00:00
|
|
|
} else {
|
|
|
|
|
this.label = this.selector;
|
|
|
|
|
}
|
2010-10-18 21:02:18 +00:00
|
|
|
return this.dsl;
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Usage:
|
2010-11-09 07:26:36 +00:00
|
|
|
* binding(name) returns the value of the first matching binding
|
2010-10-18 21:02:18 +00:00
|
|
|
*/
|
|
|
|
|
angular.scenario.dsl('binding', function() {
|
|
|
|
|
return function(name) {
|
|
|
|
|
return this.addFutureAction("select binding '" + name + "'", function($window, $document, done) {
|
2010-11-09 07:26:36 +00:00
|
|
|
var values = $document.elements().bindings(name);
|
|
|
|
|
if (!values.length) {
|
|
|
|
|
return done("Binding selector '" + name + "' did not match.");
|
2010-10-18 21:02:18 +00:00
|
|
|
}
|
2010-11-09 07:26:36 +00:00
|
|
|
done(null, values[0]);
|
2010-10-18 21:02:18 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Usage:
|
|
|
|
|
* input(name).enter(value) enters value in input with specified name
|
|
|
|
|
* input(name).check() checks checkbox
|
2011-04-23 06:10:07 +00:00
|
|
|
* input(name).select(value) selects the radio button with specified name/value
|
2011-06-05 18:44:28 +00:00
|
|
|
* input(name).val() returns the value of the input.
|
2010-10-18 21:02:18 +00:00
|
|
|
*/
|
|
|
|
|
angular.scenario.dsl('input', function() {
|
|
|
|
|
var chain = {};
|
|
|
|
|
|
|
|
|
|
chain.enter = function(value) {
|
|
|
|
|
return this.addFutureAction("input '" + this.name + "' enter '" + value + "'", function($window, $document, done) {
|
2011-09-08 20:56:29 +00:00
|
|
|
var input = $document.elements('[ng\\:model="$1"]', this.name).filter(':input');
|
2010-10-18 21:02:18 +00:00
|
|
|
input.val(value);
|
2011-05-23 21:17:55 +00:00
|
|
|
input.trigger('keydown');
|
2010-10-18 21:02:18 +00:00
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
chain.check = function() {
|
|
|
|
|
return this.addFutureAction("checkbox '" + this.name + "' toggle", function($window, $document, done) {
|
2011-09-08 20:56:29 +00:00
|
|
|
var input = $document.elements('[ng\\:model="$1"]', this.name).filter(':checkbox');
|
2010-10-18 21:02:18 +00:00
|
|
|
input.trigger('click');
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
chain.select = function(value) {
|
|
|
|
|
return this.addFutureAction("radio button '" + this.name + "' toggle '" + value + "'", function($window, $document, done) {
|
|
|
|
|
var input = $document.
|
2011-09-08 20:56:29 +00:00
|
|
|
elements('[ng\\:model="$1"][value="$2"]', this.name, value).filter(':radio');
|
2010-10-18 21:02:18 +00:00
|
|
|
input.trigger('click');
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2011-06-05 18:44:28 +00:00
|
|
|
chain.val = function() {
|
|
|
|
|
return this.addFutureAction("return input val", function($window, $document, done) {
|
2011-09-08 20:56:29 +00:00
|
|
|
var input = $document.elements('[ng\\:model="$1"]', this.name).filter(':input');
|
2011-06-05 18:44:28 +00:00
|
|
|
done(null,input.val());
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2010-10-18 21:02:18 +00:00
|
|
|
return function(name) {
|
|
|
|
|
this.name = name;
|
|
|
|
|
return chain;
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
2010-11-02 23:25:43 +00:00
|
|
|
|
2010-10-18 21:02:18 +00:00
|
|
|
/**
|
|
|
|
|
* Usage:
|
2010-10-27 18:29:51 +00:00
|
|
|
* repeater('#products table', 'Product List').count() number of rows
|
|
|
|
|
* repeater('#products table', 'Product List').row(1) all bindings in row as an array
|
|
|
|
|
* repeater('#products table', 'Product List').column('product.name') all values across all rows in an array
|
2010-10-18 21:02:18 +00:00
|
|
|
*/
|
|
|
|
|
angular.scenario.dsl('repeater', function() {
|
|
|
|
|
var chain = {};
|
|
|
|
|
|
|
|
|
|
chain.count = function() {
|
2010-11-01 23:51:15 +00:00
|
|
|
return this.addFutureAction("repeater '" + this.label + "' count", function($window, $document, done) {
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
try {
|
|
|
|
|
done(null, $document.elements().length);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
done(null, 0);
|
|
|
|
|
}
|
2010-10-18 21:02:18 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
chain.column = function(binding) {
|
2010-11-01 23:51:15 +00:00
|
|
|
return this.addFutureAction("repeater '" + this.label + "' column '" + binding + "'", function($window, $document, done) {
|
2010-11-09 07:26:36 +00:00
|
|
|
done(null, $document.elements().bindings(binding));
|
2010-10-18 21:02:18 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
chain.row = function(index) {
|
2010-11-01 23:51:15 +00:00
|
|
|
return this.addFutureAction("repeater '" + this.label + "' row '" + index + "'", function($window, $document, done) {
|
2010-10-18 21:02:18 +00:00
|
|
|
var matches = $document.elements().slice(index, index + 1);
|
|
|
|
|
if (!matches.length)
|
|
|
|
|
return done('row ' + index + ' out of bounds');
|
2010-11-09 07:26:36 +00:00
|
|
|
done(null, matches.bindings());
|
2010-10-18 21:02:18 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2010-10-27 18:29:51 +00:00
|
|
|
return function(selector, label) {
|
|
|
|
|
this.dsl.using(selector, label);
|
2010-10-18 21:02:18 +00:00
|
|
|
return chain;
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Usage:
|
2010-10-27 18:29:51 +00:00
|
|
|
* select(name).option('value') select one option
|
|
|
|
|
* select(name).options('value1', 'value2', ...) select options from a multi select
|
2010-10-18 21:02:18 +00:00
|
|
|
*/
|
|
|
|
|
angular.scenario.dsl('select', function() {
|
|
|
|
|
var chain = {};
|
|
|
|
|
|
|
|
|
|
chain.option = function(value) {
|
2010-11-01 23:51:15 +00:00
|
|
|
return this.addFutureAction("select '" + this.name + "' option '" + value + "'", function($window, $document, done) {
|
2011-09-08 20:56:29 +00:00
|
|
|
var select = $document.elements('select[ng\\:model="$1"]', this.name);
|
|
|
|
|
var option = select.find('option[value="' + value + '"]');
|
|
|
|
|
if (option.length) {
|
|
|
|
|
select.val(value);
|
|
|
|
|
} else {
|
|
|
|
|
option = select.find('option:contains("' + value + '")');
|
|
|
|
|
if (option.length) {
|
|
|
|
|
select.val(option.val());
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-10-18 21:02:18 +00:00
|
|
|
select.trigger('change');
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
chain.options = function() {
|
|
|
|
|
var values = arguments;
|
2010-11-01 23:51:15 +00:00
|
|
|
return this.addFutureAction("select '" + this.name + "' options '" + values + "'", function($window, $document, done) {
|
2011-09-08 20:56:29 +00:00
|
|
|
var select = $document.elements('select[multiple][ng\\:model="$1"]', this.name);
|
2010-10-18 21:02:18 +00:00
|
|
|
select.val(values);
|
|
|
|
|
select.trigger('change');
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return function(name) {
|
|
|
|
|
this.name = name;
|
|
|
|
|
return chain;
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Usage:
|
2010-10-27 18:29:51 +00:00
|
|
|
* element(selector, label).count() get the number of elements that match selector
|
|
|
|
|
* element(selector, label).click() clicks an element
|
|
|
|
|
* element(selector, label).query(fn) executes fn(selectedElements, done)
|
2010-11-09 06:40:57 +00:00
|
|
|
* element(selector, label).{method}() gets the value (as defined by jQuery, ex. val)
|
|
|
|
|
* element(selector, label).{method}(value) sets the value (as defined by jQuery, ex. val)
|
|
|
|
|
* element(selector, label).{method}(key) gets the value (as defined by jQuery, ex. attr)
|
|
|
|
|
* element(selector, label).{method}(key, value) sets the value (as defined by jQuery, ex. attr)
|
2010-10-18 21:02:18 +00:00
|
|
|
*/
|
|
|
|
|
angular.scenario.dsl('element', function() {
|
2011-09-15 22:05:13 +00:00
|
|
|
var KEY_VALUE_METHODS = ['attr', 'css', 'prop'];
|
2010-10-29 19:19:22 +00:00
|
|
|
var VALUE_METHODS = [
|
|
|
|
|
'val', 'text', 'html', 'height', 'innerHeight', 'outerHeight', 'width',
|
|
|
|
|
'innerWidth', 'outerWidth', 'position', 'scrollLeft', 'scrollTop', 'offset'
|
|
|
|
|
];
|
2010-10-18 21:02:18 +00:00
|
|
|
var chain = {};
|
|
|
|
|
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
chain.count = function() {
|
2010-11-01 23:51:15 +00:00
|
|
|
return this.addFutureAction("element '" + this.label + "' count", function($window, $document, done) {
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
try {
|
|
|
|
|
done(null, $document.elements().length);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
done(null, 0);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2010-10-18 21:02:18 +00:00
|
|
|
chain.click = function() {
|
2010-11-01 23:51:15 +00:00
|
|
|
return this.addFutureAction("element '" + this.label + "' click", function($window, $document, done) {
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
var elements = $document.elements();
|
|
|
|
|
var href = elements.attr('href');
|
2011-08-30 11:14:55 +00:00
|
|
|
var eventProcessDefault = elements.trigger('click')[0];
|
|
|
|
|
|
|
|
|
|
if (href && elements[0].nodeName.toUpperCase() === 'A' && eventProcessDefault) {
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
this.application.navigateTo(href, function() {
|
|
|
|
|
done();
|
2010-10-28 02:06:40 +00:00
|
|
|
}, done);
|
Lots of bug fixes in the scenario runner and a bunch of new features.
- By default the runner now creates multiple output formats as it runs. Nodes are created in the DOM with ids: json, xml, and html.
ex. $('#json').html() => json output of the runner
ex. $('#xml').html() => json output of the runner
$result is also an object tree result.
The permitted formats are html,json,xml,object.
If you don't want certain formats you can select specific ones with the new ng:scenario-output attribute on the script tag.
<script src="angular-scenario.js" ng:scenario-output="xml,json">
- Added element(...).count() that returns the number of matching elements for the selector.
- repeater(...).count() now returns 0 if no elements matched which can be used to check if a repeater is empty.
- Added toBe() matcher that does strict equality with ===
- Implement iit and ddescribe. If iit() is used instead of it() then only that test will run. If ddescribe() is used instead of describe() them only it() statements inside of it will run. Several iit/ddescribe() blocks can be used to run isolated tests.
- Implement new event based model for SpecRunner. You can now listen for events in the runner. This is useful for writing your own UI or connecting a remote process (ex. WebDriver). Event callbacks execute on the Runner instance.
Events, if fired, will always be in the below order. All events always happen
except for Failure and Error events which only happen in error conditions.
Events:
RunnerBegin
SpecBegin(spec)
StepBegin(spec, step)
StepError(spec, step, error)
StepFailure(spec, step, error)
StepEnd(spec, step)
SpecError(spec, step, error)
SpecEnd(spec)
RunnerEnd
- Only allow the browser to repaint every 10 steps. Cuts 700ms off Firefox in benchmark, 200ms off Chrome.
- Bug Fix: Manually navigate anchors on click since trigger wont work in Firefox.
2010-10-24 21:14:45 +00:00
|
|
|
} else {
|
|
|
|
|
done();
|
|
|
|
|
}
|
2010-10-18 21:02:18 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2010-10-19 20:17:49 +00:00
|
|
|
chain.query = function(fn) {
|
2010-10-27 18:29:51 +00:00
|
|
|
return this.addFutureAction('element ' + this.label + ' custom query', function($window, $document, done) {
|
2010-10-19 20:17:49 +00:00
|
|
|
fn.call(this, $document.elements(), done);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2011-01-08 06:02:23 +00:00
|
|
|
angular.forEach(KEY_VALUE_METHODS, function(methodName) {
|
2010-11-09 06:40:57 +00:00
|
|
|
chain[methodName] = function(name, value) {
|
2011-09-14 22:42:17 +00:00
|
|
|
var args = arguments,
|
|
|
|
|
futureName = (args.length == 1)
|
|
|
|
|
? "element '" + this.label + "' get " + methodName + " '" + name + "'"
|
|
|
|
|
: "element '" + this.label + "' set " + methodName + " '" + name + "' to " + "'" + value + "'";
|
|
|
|
|
|
2010-11-09 06:40:57 +00:00
|
|
|
return this.addFutureAction(futureName, function($window, $document, done) {
|
|
|
|
|
var element = $document.elements();
|
2011-09-14 22:42:17 +00:00
|
|
|
done(null, element[methodName].apply(element, args));
|
2010-11-09 06:40:57 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
2011-01-08 06:02:23 +00:00
|
|
|
angular.forEach(VALUE_METHODS, function(methodName) {
|
2010-10-29 19:19:22 +00:00
|
|
|
chain[methodName] = function(value) {
|
2011-09-14 22:42:17 +00:00
|
|
|
var args = arguments,
|
|
|
|
|
futureName = (args.length == 0)
|
|
|
|
|
? "element '" + this.label + "' " + methodName
|
|
|
|
|
: futureName = "element '" + this.label + "' set " + methodName + " to '" + value + "'";
|
|
|
|
|
|
2010-10-29 19:19:22 +00:00
|
|
|
return this.addFutureAction(futureName, function($window, $document, done) {
|
|
|
|
|
var element = $document.elements();
|
2011-09-14 22:42:17 +00:00
|
|
|
done(null, element[methodName].apply(element, args));
|
2010-10-29 19:19:22 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
2010-10-27 18:29:51 +00:00
|
|
|
return function(selector, label) {
|
|
|
|
|
this.dsl.using(selector, label);
|
2010-10-18 21:02:18 +00:00
|
|
|
return chain;
|
|
|
|
|
};
|
|
|
|
|
});
|