diff --git a/lib/expectedConditions.js b/lib/expectedConditions.js deleted file mode 100644 index 0645da43b..000000000 --- a/lib/expectedConditions.js +++ /dev/null @@ -1,370 +0,0 @@ -var webdriver = require('selenium-webdriver'); - -/* globals browser */ - -/** - * Represents a library of canned expected conditions that are useful for - * protractor, especially when dealing with non-angular apps. - * - * Each condition returns a function that evaluates to a promise. You may mix - * multiple conditions using `and`, `or`, and/or `not`. You may also - * mix these conditions with any other conditions that you write. - * - * See https://selenium.googlecode.com/git/docs/api/java/org/openqa ... - * /selenium/support/ui/ExpectedConditions.html - * - * - * @example - * var EC = protractor.ExpectedConditions; - * var button = $('#xyz'); - * var isClickable = EC.elementToBeClickable(button); - * - * browser.get(URL); - * browser.wait(isClickable, 5000); //wait for an element to become clickable - * button.click(); - * - * // You can define your own expected condition, which is a function that - * // takes no parameter and evaluates to a promise of a boolean. - * var urlChanged = function() { - * return browser.getCurrentUrl().then(function(url) { - * return url === 'http://www.angularjs.org'; - * }); - * }; - * - * // You can customize the conditions with EC.and, EC.or, and EC.not. - * // Here's a condition to wait for url to change, $('abc') element to contain - * // text 'bar', and button becomes clickable. - * var condition = EC.and(urlChanged, EC.textToBePresentInElement($('abc'), 'bar'), isClickable); - * browser.get(URL); - * browser.wait(condition, 5000); //wait for condition to be true. - * button.click(); - * - * @constructor - */ -var ExpectedConditions = function() {}; - -/** - * Negates the result of a promise. - * - * @example - * var EC = protractor.ExpectedConditions; - * var titleIsNotFoo = EC.not(EC.titleIs('Foo')); - * // Waits for title to become something besides 'foo'. - * browser.wait(titleIsNotFoo, 5000); - * - * @param {!function} expectedCondition - * - * @return {!function} An expected condition that returns the negated value. - */ -ExpectedConditions.prototype.not = function(expectedCondition) { - return function() { - return expectedCondition.call().then(function(bool) { - return !bool; - }); - }; -}; - -/** - * Helper function that is equivalent to the logical_and if defaultRet==true, - * or logical_or if defaultRet==false - * - * @private - * @param {boolean} defaultRet - * @param {Array.} fns An array of expected conditions to chain. - * - * @return {!function} An expected condition that returns a promise which - * evaluates to the result of the logical chain. - */ -ExpectedConditions.prototype.logicalChain_ = function(defaultRet, fns) { - var self = this; - return function() { - if (fns.length === 0) { - return defaultRet; - } - var fn = fns[0]; - return fn().then(function(bool) { - if (bool === defaultRet) { - return self.logicalChain_(defaultRet, fns.slice(1))(); - } else { - return !defaultRet; - } - }); - }; -}; - -/** - * Chain a number of expected conditions using logical_and, short circuiting - * at the first expected condition that evaluates to false. - * - * @example - * var EC = protractor.ExpectedConditions; - * var titleContainsFoo = EC.titleContains('Foo'); - * var titleIsNotFooBar = EC.not(EC.titleIs('FooBar')); - * // Waits for title to contain 'Foo', but is not 'FooBar' - * browser.wait(EC.and(titleContainsFoo, titleIsNotFooBar), 5000); - * - * @param {Array.} fns An array of expected conditions to 'and' together. - * - * @return {!function} An expected condition that returns a promise which - * evaluates to the result of the logical and. - */ -ExpectedConditions.prototype.and = function() { - var args = Array.prototype.slice.call(arguments); - return this.logicalChain_(true, args); -}; - -/** - * Chain a number of expected conditions using logical_or, short circuiting - * at the first expected condition that evaluates to true. - * - * @example - * var EC = protractor.ExpectedConditions; - * var titleContainsFoo = EC.titleContains('Foo'); - * var titleContainsBar = EC.titleContains('Bar'); - * // Waits for title to contain either 'Foo' or 'Bar' - * browser.wait(EC.or(titleContainsFoo, titleContainsBar), 5000); - * - * @param {Array.} fns An array of expected conditions to 'or' together. - * - * @return {!function} An expected condition that returns a promise which - * evaluates to the result of the logical or. - */ -ExpectedConditions.prototype.or = function() { - var args = Array.prototype.slice.call(arguments); - return this.logicalChain_(false, args); -}; - -/** - * Expect an alert to be present. - * - * @example - * var EC = protractor.ExpectedConditions; - * // Waits for an alert pops up. - * browser.wait(EC.alertIsPresent(), 5000); - * - * @return {!function} An expected condition that returns a promise - * representing whether an alert is present. - */ -ExpectedConditions.prototype.alertIsPresent = function() { - return function() { - return browser.switchTo().alert().then(function() { - return true; - }, function(err) { - if (err.code == webdriver.error.ErrorCode.NO_SUCH_ALERT) { - return false; - } else { - throw err; - } - }); - }; -}; - -/** - * An Expectation for checking an element is visible and enabled such that you - * can click it. - * - * @example - * var EC = protractor.ExpectedConditions; - * // Waits for the element with id 'abc' to be clickable. - * browser.wait(EC.elementToBeClickable($('#abc')), 5000); - * - * @param {!ElementFinder} elementFinder The element to check - * - * @return {!function} An expected condition that returns a promise - * representing whether the element is clickable. - */ -ExpectedConditions.prototype.elementToBeClickable = function(elementFinder) { - return this.and( - this.visibilityOf(elementFinder), - elementFinder.isEnabled.bind(elementFinder)); -}; - -/** - * An expectation for checking if the given text is present in the - * element. Returns false if the elementFinder does not find an element. - * - * @example - * var EC = protractor.ExpectedConditions; - * // Waits for the element with id 'abc' to contain the text 'foo'. - * browser.wait(EC.textToBePresentInElement($('#abc'), 'foo'), 5000); - * - * @param {!ElementFinder} elementFinder The element to check - * @param {!string} text The text to verify against - * - * @return {!function} An expected condition that returns a promise - * representing whether the text is present in the element. - */ -ExpectedConditions.prototype.textToBePresentInElement = function(elementFinder, text) { - var hasText = function() { - return elementFinder.getText().then(function(actualText) { - return actualText.indexOf(text) > -1; - }); - }; - return this.and(this.presenceOf(elementFinder), hasText); -}; - -/** - * An expectation for checking if the given text is present in the element’s - * value. Returns false if the elementFinder does not find an element. - * - * @example - * var EC = protractor.ExpectedConditions; - * // Waits for the element with id 'myInput' to contain the input 'foo'. - * browser.wait(EC.textToBePresentInElementValue($('#myInput'), 'foo'), 5000); - * - * @param {!ElementFinder} elementFinder The element to check - * @param {!string} text The text to verify against - * - * @return {!function} An expected condition that returns a promise - * representing whether the text is present in the element's value. - */ -ExpectedConditions.prototype.textToBePresentInElementValue = function(elementFinder, text) { - var hasText = function() { - return elementFinder.getAttribute('value').then(function(actualText) { - return actualText.indexOf(text) > -1; - }); - }; - return this.and(this.presenceOf(elementFinder), hasText); -}; - -/** - * An expectation for checking that the title contains a case-sensitive - * substring. - * - * @example - * var EC = protractor.ExpectedConditions; - * // Waits for the title to contain 'foo'. - * browser.wait(EC.titleContains('foo'), 5000); - * - * @param {!string} title The fragment of title expected - * - * @return {!function} An expected condition that returns a promise - * representing whether the title contains the string. - */ -ExpectedConditions.prototype.titleContains = function(title) { - return function() { - return browser.getTitle().then(function(actualTitle) { - return actualTitle.indexOf(title) > -1; - }); - }; -}; - -/** - * An expectation for checking the title of a page. - * - * @example - * var EC = protractor.ExpectedConditions; - * // Waits for the title to be 'foo'. - * browser.wait(EC.titleIs('foo'), 5000); - * - * @param {!string} title The expected title, which must be an exact match. - * - * @return {!function} An expected condition that returns a promise - * representing whether the title equals the string. - */ -ExpectedConditions.prototype.titleIs = function(title) { - return function() { - return browser.getTitle().then(function(actualTitle) { - return actualTitle === title; - }); - }; -}; - -/** - * An expectation for checking that an element is present on the DOM - * of a page. This does not necessarily mean that the element is visible. - * This is the opposite of 'stalenessOf'. - * - * @example - * var EC = protractor.ExpectedConditions; - * // Waits for the element with id 'abc' to be present on the dom. - * browser.wait(EC.presenceOf($('#abc')), 5000); - * - * @param {!ElementFinder} elementFinder The element to check - * - * @return {!function} An expected condition that returns a promise - * representing whether the element is present. - */ -ExpectedConditions.prototype.presenceOf = function(elementFinder) { - return elementFinder.isPresent.bind(elementFinder); -}; - -/** - * An expectation for checking that an element is not attached to the DOM - * of a page. This is the opposite of 'presenceOf'. - * - * @example - * var EC = protractor.ExpectedConditions; - * // Waits for the element with id 'abc' to be no longer present on the dom. - * browser.wait(EC.stalenessOf($('#abc')), 5000); - * - * @param {!ElementFinder} elementFinder The element to check - * - * @return {!function} An expected condition that returns a promise - * representing whether the element is stale. - */ -ExpectedConditions.prototype.stalenessOf = function(elementFinder) { - return this.not(this.presenceOf(elementFinder)); -}; - -/** - * An expectation for checking that an element is present on the DOM of a - * page and visible. Visibility means that the element is not only displayed - * but also has a height and width that is greater than 0. This is the opposite - * of 'invisibilityOf'. - * - * @example - * var EC = protractor.ExpectedConditions; - * // Waits for the element with id 'abc' to be visible on the dom. - * browser.wait(EC.visibilityOf($('#abc')), 5000); - * - * @param {!ElementFinder} elementFinder The element to check - * - * @return {!function} An expected condition that returns a promise - * representing whether the element is visible. - */ -ExpectedConditions.prototype.visibilityOf = function(elementFinder) { - return this.and( - this.presenceOf(elementFinder), - elementFinder.isDisplayed.bind(elementFinder)); -}; - -/** - * An expectation for checking that an element is either invisible or not - * present on the DOM. This is the opposite of 'visibilityOf'. - * - * @example - * var EC = protractor.ExpectedConditions; - * // Waits for the element with id 'abc' to be no longer visible on the dom. - * browser.wait(EC.invisibilityOf($('#abc')), 5000); - * - * @param {!ElementFinder} elementFinder The element to check - * - * @return {!function} An expected condition that returns a promise - * representing whether the element is invisible. - */ -ExpectedConditions.prototype.invisibilityOf = function(elementFinder) { - return this.not(this.visibilityOf(elementFinder)); -}; - -/** - * An expectation for checking the selection is selected. - * - * @example - * var EC = protractor.ExpectedConditions; - * // Waits for the element with id 'myCheckbox' to be selected. - * browser.wait(EC.elementToBeSelected($('#myCheckbox')), 5000); - * - * @param {!ElementFinder} elementFinder The element to check - * - * @return {!function} An expected condition that returns a promise - * representing whether the element is selected. - */ -ExpectedConditions.prototype.elementToBeSelected = function(elementFinder) { - return this.and( - this.presenceOf(elementFinder), - elementFinder.isSelected.bind(elementFinder)); -}; - -module.exports = ExpectedConditions; - diff --git a/lib/expectedConditions.ts b/lib/expectedConditions.ts new file mode 100644 index 000000000..682bcbb15 --- /dev/null +++ b/lib/expectedConditions.ts @@ -0,0 +1,367 @@ +var webdriver = require('selenium-webdriver'); + +/* globals browser */ + +/** + * Represents a library of canned expected conditions that are useful for + * protractor, especially when dealing with non-angular apps. + * + * Each condition returns a function that evaluates to a promise. You may mix + * multiple conditions using `and`, `or`, and/or `not`. You may also + * mix these conditions with any other conditions that you write. + * + * See https://selenium.googlecode.com/git/docs/api/java/org/openqa ... + * /selenium/support/ui/ExpectedConditions.html + * + * + * @example + * var EC = protractor.ExpectedConditions; + * var button = $('#xyz'); + * var isClickable = EC.elementToBeClickable(button); + * + * browser.get(URL); + * browser.wait(isClickable, 5000); //wait for an element to become clickable + * button.click(); + * + * // You can define your own expected condition, which is a function that + * // takes no parameter and evaluates to a promise of a boolean. + * var urlChanged = function() { + * return browser.getCurrentUrl().then(function(url) { + * return url === 'http://www.angularjs.org'; + * }); + * }; + * + * // You can customize the conditions with EC.and, EC.or, and EC.not. + * // Here's a condition to wait for url to change, $('abc') element to contain + * // text 'bar', and button becomes clickable. + * var condition = EC.and(urlChanged, EC.textToBePresentInElement($('abc'), 'bar'), isClickable); + * browser.get(URL); + * browser.wait(condition, 5000); //wait for condition to be true. + * button.click(); + * + * @constructor + */ +export class ExpectedConditions { + + /** + * Negates the result of a promise. + * + * @example + * var EC = protractor.ExpectedConditions; + * var titleIsNotFoo = EC.not(EC.titleIs('Foo')); + * // Waits for title to become something besides 'foo'. + * browser.wait(titleIsNotFoo, 5000); + * + * @param {!function} expectedCondition + * + * @return {!function} An expected condition that returns the negated value. + */ + not(expectedCondition: Function): Function { + return (): Function => { + return expectedCondition().then((bool: boolean): boolean => { + return !bool; + }); + }; + } + + /** + * Helper function that is equivalent to the logical_and if defaultRet==true, + * or logical_or if defaultRet==false + * + * @private + * @param {boolean} defaultRet + * @param {Array.} fns An array of expected conditions to chain. + * + * @return {!function} An expected condition that returns a promise which + * evaluates to the result of the logical chain. + */ + logicalChain_(defaultRet: boolean, fns: Array): Function { + let self = this; + return (): boolean => { + if (fns.length === 0) { + return defaultRet; + } + var fn = fns[0]; + return fn().then((bool: boolean): boolean => { + if (bool === defaultRet) { + return self.logicalChain_(defaultRet, fns.slice(1))(); + } else { + return !defaultRet; + } + }); + }; + } + + /** + * Chain a number of expected conditions using logical_and, short circuiting + * at the first expected condition that evaluates to false. + * + * @example + * var EC = protractor.ExpectedConditions; + * var titleContainsFoo = EC.titleContains('Foo'); + * var titleIsNotFooBar = EC.not(EC.titleIs('FooBar')); + * // Waits for title to contain 'Foo', but is not 'FooBar' + * browser.wait(EC.and(titleContainsFoo, titleIsNotFooBar), 5000); + * + * @param {Array.} fns An array of expected conditions to 'and' together. + * + * @return {!function} An expected condition that returns a promise which + * evaluates to the result of the logical and. + */ + and(...args: Function[]): Function { + return this.logicalChain_(true, args); + } + + /** + * Chain a number of expected conditions using logical_or, short circuiting + * at the first expected condition that evaluates to true. + * + * @example + * var EC = protractor.ExpectedConditions; + * var titleContainsFoo = EC.titleContains('Foo'); + * var titleContainsBar = EC.titleContains('Bar'); + * // Waits for title to contain either 'Foo' or 'Bar' + * browser.wait(EC.or(titleContainsFoo, titleContainsBar), 5000); + * + * @param {Array.} fns An array of expected conditions to 'or' together. + * + * @return {!function} An expected condition that returns a promise which + * evaluates to the result of the logical or. + */ + or(...args: Function[]): Function { + return this.logicalChain_(false, args); + } + + /** + * Expect an alert to be present. + * + * @example + * var EC = protractor.ExpectedConditions; + * // Waits for an alert pops up. + * browser.wait(EC.alertIsPresent(), 5000); + * + * @return {!function} An expected condition that returns a promise + * representing whether an alert is present. + */ + alertIsPresent(): Function { + return () => { + return browser.switchTo().alert().then((): boolean => { + return true; + }, (err: any) => { + if (err.code == webdriver.error.ErrorCode.NO_SUCH_ALERT) { + return false; + } else { + throw err; + } + }); + }; + } + + /** + * An Expectation for checking an element is visible and enabled such that you + * can click it. + * + * @example + * var EC = protractor.ExpectedConditions; + * // Waits for the element with id 'abc' to be clickable. + * browser.wait(EC.elementToBeClickable($('#abc')), 5000); + * + * @param {!ElementFinder} elementFinder The element to check + * + * @return {!function} An expected condition that returns a promise + * representing whether the element is clickable. + */ + elementToBeClickable(elementFinder: any): Function { + return this.and( + this.visibilityOf(elementFinder), + elementFinder.isEnabled.bind(elementFinder)); + } + + /** + * An expectation for checking if the given text is present in the + * element. Returns false if the elementFinder does not find an element. + * + * @example + * var EC = protractor.ExpectedConditions; + * // Waits for the element with id 'abc' to contain the text 'foo'. + * browser.wait(EC.textToBePresentInElement($('#abc'), 'foo'), 5000); + * + * @param {!ElementFinder} elementFinder The element to check + * @param {!string} text The text to verify against + * + * @return {!function} An expected condition that returns a promise + * representing whether the text is present in the element. + */ + textToBePresentInElement(elementFinder: any, text: string): Function { + var hasText = () => { + return elementFinder.getText().then((actualText: string): boolean => { + return actualText.indexOf(text) > -1; + }); + }; + return this.and(this.presenceOf(elementFinder), hasText); + } + + /** + * An expectation for checking if the given text is present in the element’s + * value. Returns false if the elementFinder does not find an element. + * + * @example + * var EC = protractor.ExpectedConditions; + * // Waits for the element with id 'myInput' to contain the input 'foo'. + * browser.wait(EC.textToBePresentInElementValue($('#myInput'), 'foo'), 5000); + * + * @param {!ElementFinder} elementFinder The element to check + * @param {!string} text The text to verify against + * + * @return {!function} An expected condition that returns a promise + * representing whether the text is present in the element's value. + */ + textToBePresentInElementValue(elementFinder: any, text: string): Function { + var hasText = () => { + return elementFinder.getAttribute('value') + .then((actualText: string): boolean => { + return actualText.indexOf(text) > -1; + }); + }; + return this.and(this.presenceOf(elementFinder), hasText); + } + + /** + * An expectation for checking that the title contains a case-sensitive + * substring. + * + * @example + * var EC = protractor.ExpectedConditions; + * // Waits for the title to contain 'foo'. + * browser.wait(EC.titleContains('foo'), 5000); + * + * @param {!string} title The fragment of title expected + * + * @return {!function} An expected condition that returns a promise + * representing whether the title contains the string. + */ + titleContains(title: string): Function { + return () => { + return browser.getTitle().then((actualTitle: string): boolean => { + return actualTitle.indexOf(title) > -1; + }); + }; + } + + /** + * An expectation for checking the title of a page. + * + * @example + * var EC = protractor.ExpectedConditions; + * // Waits for the title to be 'foo'. + * browser.wait(EC.titleIs('foo'), 5000); + * + * @param {!string} title The expected title, which must be an exact match. + * + * @return {!function} An expected condition that returns a promise + * representing whether the title equals the string. + */ + titleIs(title: string): Function { + return () => { + return browser.getTitle().then((actualTitle: string): boolean => { + return actualTitle === title; + }); + }; + } + + /** + * An expectation for checking that an element is present on the DOM + * of a page. This does not necessarily mean that the element is visible. + * This is the opposite of 'stalenessOf'. + * + * @example + * var EC = protractor.ExpectedConditions; + * // Waits for the element with id 'abc' to be present on the dom. + * browser.wait(EC.presenceOf($('#abc')), 5000); + * + * @param {!ElementFinder} elementFinder The element to check + * + * @return {!function} An expected condition that returns a promise + * representing whether the element is present. + */ + presenceOf(elementFinder: any): Function { + return elementFinder.isPresent.bind(elementFinder); + }; + + /** + * An expectation for checking that an element is not attached to the DOM + * of a page. This is the opposite of 'presenceOf'. + * + * @example + * var EC = protractor.ExpectedConditions; + * // Waits for the element with id 'abc' to be no longer present on the dom. + * browser.wait(EC.stalenessOf($('#abc')), 5000); + * + * @param {!ElementFinder} elementFinder The element to check + * + * @return {!function} An expected condition that returns a promise + * representing whether the element is stale. + */ + stalenessOf(elementFinder: any): Function { + return this.not(this.presenceOf(elementFinder)); + } + + /** + * An expectation for checking that an element is present on the DOM of a + * page and visible. Visibility means that the element is not only displayed + * but also has a height and width that is greater than 0. This is the opposite + * of 'invisibilityOf'. + * + * @example + * var EC = protractor.ExpectedConditions; + * // Waits for the element with id 'abc' to be visible on the dom. + * browser.wait(EC.visibilityOf($('#abc')), 5000); + * + * @param {!ElementFinder} elementFinder The element to check + * + * @return {!function} An expected condition that returns a promise + * representing whether the element is visible. + */ + visibilityOf(elementFinder: any): Function { + return this.and( + this.presenceOf(elementFinder), + elementFinder.isDisplayed.bind(elementFinder)); + } + + /** + * An expectation for checking that an element is either invisible or not + * present on the DOM. This is the opposite of 'visibilityOf'. + * + * @example + * var EC = protractor.ExpectedConditions; + * // Waits for the element with id 'abc' to be no longer visible on the dom. + * browser.wait(EC.invisibilityOf($('#abc')), 5000); + * + * @param {!ElementFinder} elementFinder The element to check + * + * @return {!function} An expected condition that returns a promise + * representing whether the element is invisible. + */ + invisibilityOf(elementFinder: any): Function { + return this.not(this.visibilityOf(elementFinder)); + } + +/** + * An expectation for checking the selection is selected. + * + * @example + * var EC = protractor.ExpectedConditions; + * // Waits for the element with id 'myCheckbox' to be selected. + * browser.wait(EC.elementToBeSelected($('#myCheckbox')), 5000); + * + * @param {!ElementFinder} elementFinder The element to check + * + * @return {!function} An expected condition that returns a promise + * representing whether the element is selected. + */ + elementToBeSelected(elementFinder: any): Function { + return this.and( + this.presenceOf(elementFinder), + elementFinder.isSelected.bind(elementFinder)); + } +} diff --git a/lib/globals.d.ts b/lib/globals.d.ts new file mode 100644 index 000000000..4e306effb --- /dev/null +++ b/lib/globals.d.ts @@ -0,0 +1 @@ +declare var browser: any; diff --git a/lib/protractor.js b/lib/protractor.js index 8d9f75db0..9a08dae00 100644 --- a/lib/protractor.js +++ b/lib/protractor.js @@ -13,7 +13,7 @@ var Plugins = require('./plugins'); var clientSideScripts = require('./clientsidescripts.js'); var ProtractorBy = require('./locators.js').ProtractorBy; -var ExpectedConditions = require('./expectedConditions.js'); +var ExpectedConditions = require('./expectedConditions').ExpectedConditions; // jshint browser: true /* global angular */ @@ -96,10 +96,10 @@ var buildElementHelper = function(ptor) { * @param {string=} opt_baseUrl A base URL to run get requests against. * @param {string=} opt_rootElement Selector element that has an ng-app in * scope. - * @param {boolean=} opt_untrackOutstandingTimeouts Whether Protractor should + * @param {boolean=} opt_untrackOutstandingTimeouts Whether Protractor should * stop tracking outstanding $timeouts. */ -var Protractor = function(webdriverInstance, opt_baseUrl, opt_rootElement, +var Protractor = function(webdriverInstance, opt_baseUrl, opt_rootElement, opt_untrackOutstandingTimeouts) { // These functions should delegate to the webdriver instance, but should // wait for Angular to sync up before performing the action. This does not @@ -215,18 +215,18 @@ var Protractor = function(webdriverInstance, opt_baseUrl, opt_rootElement, // Safari accepts data urls, but SafariDriver fails after one is used. // PhantomJS produces a "Detected a page unload event" if we use data urls var browserName = caps.get('browserName'); - if (browserName === 'internet explorer' || - browserName === 'safari' || + if (browserName === 'internet explorer' || + browserName === 'safari' || browserName === 'phantomjs') { self.resetUrl = 'about:blank'; } }); /** - * If true, Protractor will track outstanding $timeouts and report them in the + * If true, Protractor will track outstanding $timeouts and report them in the * error message if Protractor fails to synchronize with Angular in time. * @private {boolean} - */ + */ this.trackOutstandingTimeouts_ = !opt_untrackOutstandingTimeouts; /** @@ -416,7 +416,7 @@ Protractor.prototype.waitForAngular = function(opt_description) { pendingTimeoutsPromise = webdriver.promise.fulfilled({}); } var pendingHttpsPromise = self.executeScript_( - clientSideScripts.getPendingHttpRequests, + clientSideScripts.getPendingHttpRequests, 'Protractor.waitForAngular() - getting pending https' + description, self.rootEl ); @@ -565,7 +565,7 @@ Protractor.prototype.addBaseMockModules_ = function() { if (!window.NG_PENDING_TIMEOUTS) { window.NG_PENDING_TIMEOUTS = {}; } - + var extendedTimeout = function() { var args = Array.prototype.slice.call(arguments); if (typeof(args[0]) !== 'function') { @@ -577,12 +577,12 @@ Protractor.prototype.addBaseMockModules_ = function() { window.NG_PENDING_TIMEOUTS[taskId] = fn.toString(); var wrappedFn = (function(taskId_) { return function() { - delete window.NG_PENDING_TIMEOUTS[taskId_]; + delete window.NG_PENDING_TIMEOUTS[taskId_]; return fn.apply(null, arguments); }; })(taskId); args[0] = wrappedFn; - + var promise = $timeout.apply(null, args); promise.ptorTaskId_ = taskId; return promise; @@ -591,15 +591,15 @@ Protractor.prototype.addBaseMockModules_ = function() { extendedTimeout.cancel = function() { var taskId_ = arguments[0] && arguments[0].ptorTaskId_; if (taskId_) { - delete window.NG_PENDING_TIMEOUTS[taskId_]; + delete window.NG_PENDING_TIMEOUTS[taskId_]; } return $timeout.cancel.apply($timeout, arguments); }; - + return extendedTimeout; }]); }]); - } + } }, this.trackOutstandingTimeouts_); }; @@ -833,14 +833,14 @@ Protractor.prototype.debugger = function() { }; /** - * Validates that the port is free to use. This will only validate the first - * time it is called. The reason is that on subsequent calls, the port will + * Validates that the port is free to use. This will only validate the first + * time it is called. The reason is that on subsequent calls, the port will * already be bound to the debugger, so it will not be available, but that is * okay. * * @return {Promise} A promise that becomes ready when the validation * is done. The promise will resolve to a boolean which represents whether - * this is the first time that the debugger is called. + * this is the first time that the debugger is called. */ Protractor.prototype.validatePortAvailability_ = function(port) { if (this.debuggerValidated_) { @@ -853,7 +853,7 @@ Protractor.prototype.validatePortAvailability_ = function(port) { // Resolve doneDeferred if port is available. var net = require('net'); var tester = net.connect({port: port}, function() { - doneDeferred.reject('Port ' + port + + doneDeferred.reject('Port ' + port + ' is already in use. Please specify ' + 'another port to debug.'); }); tester.once('error', function (err) { @@ -863,7 +863,7 @@ Protractor.prototype.validatePortAvailability_ = function(port) { }).end(); } else { doneDeferred.reject( - 'Unexpected failure testing for port ' + port + ': ' + + 'Unexpected failure testing for port ' + port + ': ' + JSON.stringify(err)); } }); @@ -1074,8 +1074,8 @@ Protractor.prototype.enterRepl = function(opt_debugPort) { var onStartFn = function() { log.puts(); log.puts('------- Element Explorer -------'); - log.puts('Starting WebDriver debugger in a child process. Element ' + - 'Explorer is still beta, please report issues at ' + + log.puts('Starting WebDriver debugger in a child process. Element ' + + 'Explorer is still beta, please report issues at ' + 'github.com/angular/protractor'); log.puts(); log.puts('Type to see a list of locator strategies.'); @@ -1128,12 +1128,12 @@ Protractor.prototype.pause = function(opt_debugPort) { * * @param {webdriver.WebDriver} webdriver The configured webdriver instance. * @param {string=} opt_baseUrl A URL to prepend to relative gets. - * @param {boolean=} opt_untrackOutstandingTimeouts Whether Protractor should + * @param {boolean=} opt_untrackOutstandingTimeouts Whether Protractor should * stop tracking outstanding $timeouts. * @return {Protractor} */ -exports.wrapDriver = function(webdriver, opt_baseUrl, opt_rootElement, +exports.wrapDriver = function(webdriver, opt_baseUrl, opt_rootElement, opt_untrackOutstandingTimeouts) { - return new Protractor(webdriver, opt_baseUrl, opt_rootElement, + return new Protractor(webdriver, opt_baseUrl, opt_rootElement, opt_untrackOutstandingTimeouts); };