From ab9085d475298ce711d0c2b15d484b0bd17fdc80 Mon Sep 17 00:00:00 2001 From: Andreas Tolfsen Date: Thu, 6 Apr 2017 23:37:04 +0100 Subject: [PATCH] Bug 1354323 - Accept string text for sendKeysToDialog command; r=automatedtester As a follow-up to https://bugzilla.mozilla.org/show_bug.cgi?id=1354323, this makes the Marionette sendKeysToDialog command take a text field with a string, instead of the value field with an array of strings. The relevant WebDriver specification change is https://github.com/w3c/webdriver/pull/889. Fixes: https://github.com/mozilla/geckodriver/issues/607 MozReview-Commit-ID: AY52pAK2582 --HG-- extra : rebase_source : f767ae09e5f415e6e944ececfb83c442f23407f3 --- .../client/marionette_driver/marionette.py | 2 +- testing/marionette/driver.js | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/testing/marionette/client/marionette_driver/marionette.py b/testing/marionette/client/marionette_driver/marionette.py index f00a644fc7de..2ab2256b7490 100644 --- a/testing/marionette/client/marionette_driver/marionette.py +++ b/testing/marionette/client/marionette_driver/marionette.py @@ -540,7 +540,7 @@ class Alert(object): def send_keys(self, *string): """Send keys to the currently displayed text input area in an open tab modal dialog.""" - body = {"value": Marionette.convert_keys(*string)} + body = {"text": Marionette.convert_keys(*string)} self.marionette._send_message("sendKeysToDialog", body) diff --git a/testing/marionette/driver.js b/testing/marionette/driver.js index 546eafc02103..1d4303e006d8 100644 --- a/testing/marionette/driver.js +++ b/testing/marionette/driver.js @@ -2648,10 +2648,23 @@ GeckoDriver.prototype.getTextFromDialog = function (cmd, resp) { }; /** + * Set the user prompt's value field. + * * Sends keys to the input field of a currently displayed modal, or * returns a no such alert error if no modal is currently displayed. If * a tab modal is currently displayed but has no means for text input, * an element not visible error is returned. + * + * @param {string} text + * Input to the user prompt's value field. + * + * @throws {ElementNotInteractableError} + * If the current user prompt is an alert or confirm. + * @throws {NoSuchAlertError} + * If there is no current user prompt. + * @throws {UnsupportedOperationError} + * If the current user prompt is something other than an alert, + * confirm, or a prompt. */ GeckoDriver.prototype.sendKeysToDialog = function (cmd, resp) { let win = assert.window(this.getCurrentWindow()); @@ -2665,7 +2678,7 @@ GeckoDriver.prototype.sendKeysToDialog = function (cmd, resp) { } event.sendKeysToElement( - cmd.parameters.value, + cmd.parameters.text, loginTextbox, {ignoreVisibility: true}, this.dialog.window ? this.dialog.window : win);