Bug 1354323 - Accept string text for sendKeysToDialog command; r=automatedtester a=test-only
authorAndreas Tolfsen <ato@mozilla.com>
Thu, 06 Apr 2017 23:37:04 +0100
changeset 379511 55b6fa40ef642b91c69b0f7e25d42d0809ae477d
parent 379510 0fe6857edafffdf71681d78b52d30802a287ebe9
child 379512 2b1b20e6907ecc218cc19d5c6d976214edbdbe1c
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester, test-only
bugs1354323
milestone53.0
Bug 1354323 - Accept string text for sendKeysToDialog command; r=automatedtester a=test-only 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");