diff --git a/lib/clientsidescripts.js b/lib/clientsidescripts.js index ba6b61585..80b1ec223 100644 --- a/lib/clientsidescripts.js +++ b/lib/clientsidescripts.js @@ -305,7 +305,7 @@ clientSideScripts.findSelectedOption = function() { * arguments[0] {Element} The scope of the search. * arguments[1] {string} The model name. * - * @return {Array.} The matching select elements. */ clientSideScripts.findSelectedOptions = function() { var using = arguments[0] || document; diff --git a/lib/protractor.js b/lib/protractor.js index 27951ef95..085897b76 100644 --- a/lib/protractor.js +++ b/lib/protractor.js @@ -20,14 +20,17 @@ for (foo in webdriver) { * @param {Object} to * @param {Object} from * @param {string} fnName + * @param {function=} setupFn */ -var mixin = function(to, from, fnName) { +var mixin = function(to, from, fnName, setupFn) { to[fnName] = function() { + if (setupFn) { + setupFn(); + } return from[fnName].apply(from, arguments); } }; - /** * @param {webdriver.WebDriver} webdriver * @param {string=} opt_baseUrl A base URL to run get requests against. @@ -36,10 +39,19 @@ var mixin = function(to, from, fnName) { * @constructor */ var Protractor = function(webdriver, opt_baseUrl, opt_rootElement) { + // These functions should delegate to the webdriver instance, but should + // wait for Angular to sync up before performing the action. This does not + // include functions which are overridden by protractor below. + var methodsToSync = ['getCurrentUrl', 'getPageSource', 'getTitle']; + // Mix all other driver functionality into Protractor. - for (var foo in webdriver) { - if(!this[foo] && typeof webdriver[foo] == 'function') { - mixin(this, webdriver, foo); + for (var method in webdriver) { + if(!this[method] && typeof webdriver[method] == 'function') { + if (methodsToSync.indexOf(method) !== -1) { + mixin(this, webdriver, method, this.waitForAngular.bind(this)); + } else { + mixin(this, webdriver, method); + } } } @@ -227,6 +239,7 @@ Protractor.prototype.findElements = function(locator, varArgs) { * the element is present on the page. */ Protractor.prototype.isElementPresent = function(locatorOrElement, varArgs) { + this.waitForAngular(); if (locatorOrElement.findArrayOverride) { return locatorOrElement.findArrayOverride(this.driver).then(function(arr) { return !!arr.length;