Bug 1348782: Updated expected key parameter for sendKeysToElement. r=ato

The expected command parameter has been updated from `value`
to `text`. This aligns marionette with W3C WebDriver
Send Keys To Element command.

MozReview-Commit-ID: EkQ1UJ58V7f

--HG--
extra : rebase_source : 1706113816eb4184334330e237e07c1f480d4500
This commit is contained in:
David Burns 2017-03-24 21:37:43 +00:00
Родитель 40056ad049
Коммит 7e5554522e
4 изменённых файлов: 19 добавлений и 17 удалений

Просмотреть файл

@ -98,10 +98,15 @@ class HTMLElement(object):
body = {"id": self.id}
return self.marionette._send_message("getElementText", body, key="value")
def send_keys(self, *string):
"""Sends the string via synthesized keypresses to the element."""
keys = Marionette.convert_keys(*string)
body = {"id": self.id, "value": keys}
def send_keys(self, *strings):
"""Sends the string via synthesized keypresses to the element.
If an array is passed in like `marionette.send_keys(Keys.SHIFT, "a")` it
will be joined into a string.
If an integer is passed in like `marionette.send_keys(1234)` it will be
coerced into a string.
"""
keys = Marionette.convert_keys(*strings)
body = {"id": self.id, "text": keys}
self.marionette._send_message("sendKeysToElement", body)
def clear(self):
@ -835,7 +840,7 @@ class Marionette(object):
else:
for i in range(len(val)):
typing.append(val[i])
return typing
return "".join(typing)
def get_permission(self, perm):
script = """

Просмотреть файл

@ -2095,19 +2095,18 @@ GeckoDriver.prototype.getElementRect = function*(cmd, resp) {
*/
GeckoDriver.prototype.sendKeysToElement = function*(cmd, resp) {
let win = assert.window(this.getCurrentWindow());
let {id, value} = cmd.parameters;
assert.defined(value, `Expected character sequence: ${value}`);
let {id, text} = cmd.parameters;
assert.string(text);
switch (this.context) {
case Context.CHROME:
let el = this.curBrowser.seenEls.get(id, {frame: win});
yield interaction.sendKeysToElement(
el, value, true, this.a11yChecks);
el, text, true, this.a11yChecks);
break;
case Context.CONTENT:
yield this.listener.sendKeysToElement(id, value);
yield this.listener.sendKeysToElement(id, text);
break;
}
};

Просмотреть файл

@ -1283,13 +1283,13 @@ function focusElement(element) {
}
/**
* @param {Array.<string>} keySequence
* @param {string} keyString
* @param {Element} element
* @param {Object.<string, boolean>=} opts
* @param {Window=} window
*/
event.sendKeysToElement = function (
keySequence, el, opts = {}, window = undefined) {
keyString, el, opts = {}, window = undefined) {
if (opts.ignoreVisibility || element.isVisible(el)) {
focusElement(el);
@ -1300,9 +1300,8 @@ event.sendKeysToElement = function (
modifiers[modifier] = false;
}
let value = keySequence.join("");
for (let i = 0; i < value.length; i++) {
let c = value.charAt(i);
for (let i = 0; i < keyString.length; i++) {
let c = keyString.charAt(i);
event.sendSingleKey(c, modifiers, window);
}

Просмотреть файл

@ -1462,8 +1462,7 @@ function isElementSelected(id) {
function* sendKeysToElement(id, val) {
let el = seenEls.get(id, curContainer);
if (el.type == "file") {
let path = val.join("");
yield interaction.uploadFile(el, path);
yield interaction.uploadFile(el, val);
} else {
yield interaction.sendKeysToElement(
el, val, false, capabilities.get("moz:accessibilityChecks"));