Comparing version 1.0.0-rc1 to 1.0.0
@@ -173,11 +173,11 @@ /** | ||
* .findById('username') | ||
* .clickElement() | ||
* .click() | ||
* .type(username) | ||
* .end() | ||
* .findById('password') | ||
* .clickElement() | ||
* .click() | ||
* .type(password) | ||
* .end() | ||
* .findById('login') | ||
* .clickElement() | ||
* .click() | ||
* .end(); | ||
@@ -241,3 +241,3 @@ * }); | ||
* @borrows module:leadfoot/Session#getActiveElement as module:leadfoot/Command#getActiveElement | ||
* @borrows module:leadfoot/Session#type as module:leadfoot/Command#type | ||
* @borrows module:leadfoot/Session#pressKeys as module:leadfoot/Command#pressKeys | ||
* @borrows module:leadfoot/Session#getOrientation as module:leadfoot/Command#getOrientation | ||
@@ -250,3 +250,3 @@ * @borrows module:leadfoot/Session#setOrientation as module:leadfoot/Command#setOrientation | ||
* @borrows module:leadfoot/Session#moveMouseTo as module:leadfoot/Command#moveMouseTo | ||
* @borrows module:leadfoot/Session#click as module:leadfoot/Command#click | ||
* @borrows module:leadfoot/Session#clickMouseButton as module:leadfoot/Command#clickMouseButton | ||
* @borrows module:leadfoot/Session#pressMouseButton as module:leadfoot/Command#pressMouseButton | ||
@@ -310,6 +310,6 @@ * @borrows module:leadfoot/Session#releaseMouseButton as module:leadfoot/Command#releaseMouseButton | ||
* @borrows module:leadfoot/Session#setPageLoadTimeout as module:leadfoot/Command#setPageLoadTimeout | ||
* @borrows module:leadfoot/Element#click as module:leadfoot/Command#clickElement | ||
* @borrows module:leadfoot/Element#click as module:leadfoot/Command#click | ||
* @borrows module:leadfoot/Element#submit as module:leadfoot/Command#submit | ||
* @borrows module:leadfoot/Element#getVisibleText as module:leadfoot/Command#getVisibleText | ||
* @borrows module:leadfoot/Element#type as module:leadfoot/Command#typeElement | ||
* @borrows module:leadfoot/Element#type as module:leadfoot/Command#type | ||
* @borrows module:leadfoot/Element#getTagName as module:leadfoot/Command#getTagName | ||
@@ -319,3 +319,5 @@ * @borrows module:leadfoot/Element#clearValue as module:leadfoot/Command#clearValue | ||
* @borrows module:leadfoot/Element#isEnabled as module:leadfoot/Command#isEnabled | ||
* @borrows module:leadfoot/Element#getSpecAttribute as module:leadfoot/Command#getSpecAttribute | ||
* @borrows module:leadfoot/Element#getAttribute as module:leadfoot/Command#getAttribute | ||
* @borrows module:leadfoot/Element#getProperty as module:leadfoot/Command#getProperty | ||
* @borrows module:leadfoot/Element#equals as module:leadfoot/Command#equals | ||
@@ -503,3 +505,3 @@ * @borrows module:leadfoot/Element#isDisplayed as module:leadfoot/Command#isDisplayed | ||
* {@link module:leadfoot/Element} or an array of Elements to be provided as its only argument. The provided | ||
* element(s) will be used as the context for subsequent element method invocations (`clickElement`, etc.). If | ||
* element(s) will be used as the context for subsequent element method invocations (`click`, etc.). If | ||
* the `setContext` method is not called, the element context from the parent will be passed through unmodified. | ||
@@ -708,11 +710,11 @@ * | ||
// TODO: Test | ||
// TODO: Add unit test | ||
if (chaiAsPromised) { | ||
chaiAsPromised.transferPromiseness = function (assertion, promise) { | ||
assertion.then = promise.then.bind(promise); | ||
Object.keys(promise.constructor.prototype).forEach(function (method) { | ||
for (var method in promise) { | ||
if (typeof promise[method] === 'function') { | ||
assertion[method] = promise[method].bind(promise); | ||
} | ||
}); | ||
} | ||
}; | ||
@@ -719,0 +721,0 @@ } |
@@ -233,3 +233,3 @@ /** | ||
active: deprecate('active', 'getActiveElement'), | ||
clickElement: deprecateElementSig('clickElement', 'click'), | ||
clickElement: deprecateElementAndStandardSig('clickElement', 'click'), | ||
submit: deprecateElementSig('submit'), | ||
@@ -287,8 +287,4 @@ text: function (element) { | ||
// This is not backwards-compatible because it is impossible to know whether someone is expecting this to | ||
// work like the old element `type` because they have not converted their code yet, or like the new session | ||
// `type` because they have | ||
type: deprecateElementSig('type', 'type'), | ||
keys: deprecate('keys', 'type'), | ||
type: deprecateElementSig('type'), | ||
keys: deprecate('keys', 'pressKeys'), | ||
getTagName: deprecateElementSig('getTagName'), | ||
@@ -302,13 +298,13 @@ clear: deprecateElementAndStandardSig('clear', 'clearValue'), | ||
if (element && element.elementId) { | ||
warn('Command#getValue(element)', 'Command#find then Command#getAttribute(\'value\'), or ' + | ||
warn('Command#getValue(element)', 'Command#find then Command#getProperty(\'value\'), or ' + | ||
'Command#find then Command#then(function (element) { ' + | ||
'return element.getAttribute(\'value\'); }'); | ||
'return element.getProperty(\'value\'); }'); | ||
return new this.constructor(this, function () { | ||
return element.getAttribute('value'); | ||
return element.getProperty('value'); | ||
}); | ||
} | ||
warn('Command#getValue', 'Command#find then Command#getAttribute(\'value\')'); | ||
return this.getAttribute('value'); | ||
warn('Command#getValue', 'Command#find then Command#getProperty(\'value\')'); | ||
return this.getProperty('value'); | ||
}, | ||
@@ -347,23 +343,8 @@ equalsElement: function (element, other) { | ||
click: function (button) { | ||
return new this.constructor(this, function () { | ||
if (this.context.length) { | ||
warn( | ||
'Command#click on a retrieved element', | ||
'Command#clickElement', | ||
'This is necessary to disambiguate between a click at the current mouse position, ' + | ||
'or a click on the element.' | ||
); | ||
if (typeof button === 'number') { | ||
warn('Command#click(button)', 'Command#clickMouseButton(button)'); | ||
return this.clickMouseButton(button); | ||
} | ||
if (this.context.isSingle) { | ||
return this.context[0].click(); | ||
} | ||
else { | ||
return Promise.all(this.context.map(function (element) { | ||
return element.click(); | ||
})); | ||
} | ||
} | ||
return this.session.click(button); | ||
}); | ||
return Command.prototype.click.apply(this, arguments); | ||
}, | ||
@@ -567,4 +548,2 @@ buttonDown: deprecate('buttonDown', 'pressMouseButton'), | ||
// TODO: type -> typeElement | ||
strategies.suffixes.forEach(function (suffix, index) { | ||
@@ -571,0 +550,0 @@ function addStrategy(method, toMethod, suffix, wdSuffix, using) { |
@@ -175,7 +175,7 @@ /* global window:false */ | ||
/** | ||
* Types into the element. This method works the same as the {@link module:leadfoot/Session#type} method | ||
* Types into the element. This method works the same as the {@link module:leadfoot/Session#pressKeys} method | ||
* except that any modifier keys are automatically released at the end of the command. | ||
* | ||
* @param {string|string[]} value | ||
* The text to type in the remote environment. See {@link module:leadfoot/Session#type} for more information. | ||
* The text to type in the remote environment. See {@link module:leadfoot/Session#pressKeys} for more information. | ||
* | ||
@@ -243,4 +243,8 @@ * @returns {Promise.<void>} | ||
/** | ||
* Gets a property or attribute of the element, using the following algorithm: | ||
* Gets a property or attribute of the element according to the WebDriver specification algorithm. Use of this | ||
* method is not recommended; instead, use {@link module:leadfoot/Element#getAttribute} to retrieve DOM attributes | ||
* and {@link module:leadfoot/Element#getProperty} to retrieve DOM properties. | ||
* | ||
* This method uses the following algorithm on the server to determine what value to return: | ||
* | ||
* 1. If `name` is 'style', returns the `style.cssText` property of the element. | ||
@@ -265,6 +269,6 @@ * 2. If the attribute exists and is a boolean attribute, returns 'true' if the attribute is true, or null | ||
*/ | ||
getAttribute: function (name) { | ||
getSpecAttribute: function (name) { | ||
var self = this; | ||
return this._get('attribute/$0', null, [ name ]).then(function (value) { | ||
if (self.session.capabilities.brokenNullGetAttribute && (value === '' || value === undefined)) { | ||
if (self.session.capabilities.brokenNullGetSpecAttribute && (value === '' || value === undefined)) { | ||
return self.session.execute(/* istanbul ignore next */ function (element, name) { | ||
@@ -290,2 +294,24 @@ return element.hasAttribute(name); | ||
/** | ||
* Gets an attribute of the element. | ||
* | ||
* @see Element#getProperty to retrieve an element property. | ||
* @param {string} name The name of the attribute. | ||
* @returns {Promise.<string>} The value of the attribute, or `null` if no such attribute exists. | ||
*/ | ||
getAttribute: function (name) { | ||
return this.session.execute('return arguments[0].getAttribute(arguments[1]);', [ this, name ]); | ||
}, | ||
/** | ||
* Gets a property of the element. | ||
* | ||
* @see Element#getAttribute to retrieve an element attribute. | ||
* @param {string} name The name of the property. | ||
* @returns {Promise.<any>} The value of the property. | ||
*/ | ||
getProperty: function (name) { | ||
return this.session.execute('return arguments[0][arguments[1]];', [ this, name ]); | ||
}, | ||
/** | ||
* Determines if this element is equal to another element. | ||
@@ -292,0 +318,0 @@ * |
@@ -15,3 +15,3 @@ /** | ||
* | ||
* @param {any[]=} args | ||
* @param {Array.<any>=} args | ||
* An array of arguments to pass to the poller function when it is invoked. | ||
@@ -18,0 +18,0 @@ * |
@@ -9,5 +9,5 @@ /** | ||
/** | ||
* A list of special keys that can be used with the `type` function. | ||
* A list of special keys that can be used with the `pressKeys` and `type` functions. | ||
* | ||
* @see {@link module:leadfoot/Session#type} for usage details. | ||
* @see {@link module:leadfoot/Session#pressKeys} for usage details. | ||
* @enum {string} | ||
@@ -14,0 +14,0 @@ */ |
{ | ||
"name": "leadfoot", | ||
"version": "1.0.0-rc1", | ||
"version": "1.0.0", | ||
"description": "Leadfoot. A JavaScript client library that brings cross-platform consistency to the Selenium WebDriver API.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -236,2 +236,3 @@ /* global document:false */ | ||
* @type {module:leadfoot/Session} | ||
* @default Session | ||
*/ | ||
@@ -243,2 +244,3 @@ sessionConstructor: Session, | ||
* @type {boolean} | ||
* @default | ||
*/ | ||
@@ -494,3 +496,3 @@ fixSessionCapabilities: true, | ||
brokenHtmlTagName: false, | ||
brokenNullGetAttribute: false, | ||
brokenNullGetSpecAttribute: false, | ||
@@ -548,4 +550,4 @@ // SafariDriver-specific | ||
// that do not exist | ||
testedCapabilities.brokenNullGetAttribute = session.findByTagName('html').then(function (element) { | ||
return element.getAttribute('nonexisting'); | ||
testedCapabilities.brokenNullGetSpecAttribute = session.findByTagName('html').then(function (element) { | ||
return element.getSpecAttribute('nonexisting'); | ||
}).then(function (value) { | ||
@@ -552,0 +554,0 @@ return value !== null; |
@@ -778,3 +778,3 @@ /*global document:false, window:false */ | ||
* | ||
* @param {?string} windowHandle | ||
* @param {string=} windowHandle | ||
* The name of the window to resize. See {@link module:leadfoot/Session#switchToWindow} to learn about valid | ||
@@ -807,3 +807,3 @@ * window names. Omit this argument to resize the currently focused window. | ||
* | ||
* @param {?string} windowHandle | ||
* @param {string=} windowHandle | ||
* The name of the window to query. See {@link module:leadfoot/Session#switchToWindow} to learn about valid | ||
@@ -826,3 +826,3 @@ * window names. Omit this argument to query the currently focused window. | ||
* | ||
* @param {?string} windowHandle | ||
* @param {string=} windowHandle | ||
* The name of the window to move. See {@link module:leadfoot/Session#switchToWindow} to learn about valid | ||
@@ -855,3 +855,3 @@ * window names. Omit this argument to move the currently focused window. | ||
* | ||
* @param {?string} windowHandle | ||
* @param {string=} windowHandle | ||
* The name of the window to query. See {@link module:leadfoot/Session#switchToWindow} to learn about valid | ||
@@ -879,3 +879,3 @@ * window names. Omit this argument to query the currently focused window. | ||
* | ||
* @param {?string} windowHandle | ||
* @param {string=} windowHandle | ||
* The name of the window to resize. See {@link module:leadfoot/Session#switchToWindow} to learn about valid | ||
@@ -1128,3 +1128,3 @@ * window names. Omit this argument to resize the currently focused window. | ||
*/ | ||
type: function (keys) { | ||
pressKeys: function (keys) { | ||
if (!Array.isArray(keys)) { | ||
@@ -1216,7 +1216,7 @@ keys = [ keys ]; | ||
* | ||
* @param {?Element} element | ||
* @param {Element=} element | ||
* The element to move the mouse to. If x-offset and y-offset are not specified, the mouse will be moved to the | ||
* centre of the element. | ||
* | ||
* @param {?number} xOffset | ||
* @param {number=} xOffset | ||
* The x-offset of the cursor, maybe in CSS pixels, relative to the left edge of the specified element’s | ||
@@ -1226,3 +1226,3 @@ * bounding client rectangle. If no element is specified, the offset is relative to the previous position of the | ||
* | ||
* @param {?number} yOffset | ||
* @param {number=} yOffset | ||
* The y-offset of the cursor, maybe in CSS pixels, relative to the top edge of the specified element’s bounding | ||
@@ -1278,5 +1278,6 @@ * client rectangle. If no element is specified, the offset is relative to the previous position of the mouse, | ||
/** | ||
* Clicks a mouse button. | ||
* Clicks a mouse button at the point where the mouse cursor is currently positioned. This method may fail to | ||
* execute with an error if the mouse has not been moved anywhere since the page was loaded. | ||
* | ||
* @param {?number} button | ||
* @param {number=} button | ||
* The button to click. 0 corresponds to the primary mouse button, 1 to the middle mouse button, 2 to the | ||
@@ -1287,3 +1288,3 @@ * secondary mouse button. Numbers above 2 correspond to any additional buttons a mouse might provide. | ||
*/ | ||
click: function (button) { | ||
clickMouseButton: function (button) { | ||
if (this.capabilities.brokenMouseEvents) { | ||
@@ -1312,3 +1313,3 @@ return this.execute(simulateMouse, [ { | ||
* | ||
* @param {?number} button The button to press. See {@link module:leadfoot/Session#click} for available options. | ||
* @param {number=} button The button to press. See {@link module:leadfoot/Session#click} for available options. | ||
* @returns {Promise.<void>} | ||
@@ -1333,3 +1334,3 @@ */ | ||
* | ||
* @param {?number} button The button to press. See {@link module:leadfoot/Session#click} for available options. | ||
* @param {number=} button The button to press. See {@link module:leadfoot/Session#click} for available options. | ||
* @returns {Promise.<void>} | ||
@@ -1442,11 +1443,11 @@ */ | ||
* @method | ||
* @param {?Element} element | ||
* @param {Element=} element | ||
* An element to scroll to. The window will be scrolled so the element is as close to the top-left corner of the | ||
* window as possible. | ||
* | ||
* @param {?number} xOffset | ||
* @param {number=} xOffset | ||
* An optional x-offset, relative to the left edge of the element, in CSS pixels. If no element is specified, | ||
* the offset is relative to the previous scroll position of the window. | ||
* | ||
* @param {?number} yOffset | ||
* @param {number=} yOffset | ||
* An optional y-offset, relative to the top edge of the element, in CSS pixels. If no element is specified, | ||
@@ -1453,0 +1454,0 @@ * the offset is relative to the previous scroll position of the window. |
@@ -139,5 +139,5 @@ /** | ||
* | ||
* @property {boolean} brokenNullGetAttribute | ||
* @property {boolean} brokenNullGetSpecAttribute | ||
* Environments with this capability incorrectly return an empty string instead of `null` for attributes that do not | ||
* exist. This issue is automatically corrected. | ||
* exist when using the `getSpecAttribute` retrieval method. This issue is automatically corrected. | ||
* | ||
@@ -144,0 +144,0 @@ * @property {boolean} brokenRefresh |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
192978
5093
0