Bug 1354323 - Accept string text for sendKeysToDialog command; r?automatedtester draft
authorAndreas Tolfsen <ato@mozilla.com>
Thu, 06 Apr 2017 23:37:04 +0100
changeset 557482 a14a4db16c94b5565d06b08fa87f51beebdfc284
parent 557282 facaf90aeaaf6d7cf5e2966f9f918319536bddea
child 623079 ec269275c62f1a1eaf26bc8e2319a735e6ad1284
push id52745
push userbmo:ato@mozilla.com
push dateThu, 06 Apr 2017 22:39:45 +0000
reviewersautomatedtester
bugs1354323
milestone55.0a1
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
testing/marionette/client/marionette_driver/marionette.py
testing/marionette/driver.js
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -535,17 +535,17 @@ class Alert(object):
     @property
     def text(self):
         """Return the currently displayed text in a tab modal."""
         return self.marionette._send_message("getTextFromDialog", key="value")
 
     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)
 
 
 class Marionette(object):
     """Represents a Marionette connection to a browser or device."""
 
     CONTEXT_CHROME = "chrome"  # non-browser content: windows, dialogs, etc.
     CONTEXT_CONTENT = "content"  # browser content: iframes, divs, etc.
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -2643,34 +2643,47 @@ GeckoDriver.prototype.getTextFromDialog 
   assert.window(this.getCurrentWindow());
   this._checkIfAlertIsPresent();
 
   let {infoBody} = this.dialog.ui;
   resp.body.value = infoBody.textContent;
 };
 
 /**
+ * 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());
   this._checkIfAlertIsPresent();
 
   // see toolkit/components/prompts/content/commonDialog.js
   let {loginContainer, loginTextbox} = this.dialog.ui;
   if (loginContainer.hidden) {
     throw new ElementNotInteractableError(
         "This prompt does not accept text input");
   }
 
   event.sendKeysToElement(
-      cmd.parameters.value,
+      cmd.parameters.text,
       loginTextbox,
       {ignoreVisibility: true},
       this.dialog.window ? this.dialog.window : win);
 };
 
 GeckoDriver.prototype._checkIfAlertIsPresent = function () {
   if (!this.dialog || !this.dialog.ui) {
     throw new NoAlertOpenError("No modal dialog is currently open");