diff --git a/lib/clientsidescripts.js b/lib/clientsidescripts.js
index b47d7dc6d..bf328048b 100644
--- a/lib/clientsidescripts.js
+++ b/lib/clientsidescripts.js
@@ -475,6 +475,18 @@ functions.evaluate = function(element, expression) {
return angular.element(element).scope().$eval(expression);
};
+functions.allowAnimations = function(element, value) {
+ var ngElement = angular.element(element);
+ if (ngElement.allowAnimations) {
+ // AngularDart: $testability API.
+ return ngElement.allowAnimations(value);
+ } else {
+ // AngularJS
+ var enabledFn = ngElement.injector().get('$animate').enabled;
+ return (value == null) ? enabledFn() : enabledFn(value);
+ }
+};
+
/**
* Return the current url using $location.absUrl().
*
diff --git a/lib/protractor.js b/lib/protractor.js
index dfe85eb65..d45b99c1e 100644
--- a/lib/protractor.js
+++ b/lib/protractor.js
@@ -106,7 +106,7 @@ var buildElementHelper = function(ptor, opt_usingChain) {
var elementFinder = {};
var webElementFns = WEB_ELEMENT_FUNCTIONS.concat(
- ['findElements', 'isElementPresent', 'evaluate']);
+ ['findElements', 'isElementPresent', 'evaluate', 'allowAnimations']);
webElementFns.forEach(function(fnName) {
elementFinder[fnName] = function() {
var callerError = new Error();
@@ -780,6 +780,12 @@ Protractor.prototype.wrapWebElement = function(element) {
element, expression);
};
+ element.allowAnimations = function(value) {
+ thisPtor.waitForAngular();
+ return element.getDriver().executeScript(clientSideScripts.allowAnimations,
+ element, value);
+ };
+
return element;
};
diff --git a/spec/basic/elements_spec.js b/spec/basic/elements_spec.js
index a408d580a..9238f2da8 100644
--- a/spec/basic/elements_spec.js
+++ b/spec/basic/elements_spec.js
@@ -158,7 +158,8 @@ describe('ElementFinder', function() {
{index: 2, text: 'form'},
{index: 3, text: 'async'},
{index: 4, text: 'conflict'},
- {index: 5, text: 'polling'}
+ {index: 5, text: 'polling'},
+ {index: 6, text: 'animation'}
]);
});
@@ -186,7 +187,8 @@ describe('ElementFinder', function() {
newExpected('form'),
newExpected('async'),
newExpected('conflict'),
- newExpected('polling')
+ newExpected('polling'),
+ newExpected('animation')
]);
});
@@ -197,7 +199,7 @@ describe('ElementFinder', function() {
return i++;
});
- expect(labels).toEqual([1, 2, 3, 4, 5, 6]);
+ expect(labels).toEqual([1, 2, 3, 4, 5, 6, 7]);
});
it('should export an isPresent helper', function() {
@@ -207,6 +209,20 @@ describe('ElementFinder', function() {
expect(element(by.binding('nopenopenope')).isPresent()).toBe(false);
});
+ it('should export an allowAnimations helper', function() {
+ browser.get('index.html#/animation');
+ var animationTop = element(by.id('animationTop'));
+ var toggledNode = element(by.id('toggledNode'));
+
+ expect(animationTop.allowAnimations()).toBe(true);
+ animationTop.allowAnimations(false);
+ expect(animationTop.allowAnimations()).toBe(false);
+
+ expect(toggledNode.isPresent()).toBe(true);
+ element(by.id('checkbox')).click();
+ expect(toggledNode.isPresent()).toBe(false);
+ });
+
it('should keep a reference to the original locator', function() {
browser.get('index.html#/form');
diff --git a/testapp/alt_root_index.html b/testapp/alt_root_index.html
index 42a86b8ed..79a796a41 100644
--- a/testapp/alt_root_index.html
+++ b/testapp/alt_root_index.html
@@ -28,6 +28,7 @@
+
@@ -36,6 +37,7 @@
+