title: Press Enter key in Selenium script
body: <p>I am using Selenium Server (v2.21) and Selenium Java Client (v.2.21.0) to automate a web form that needs to have the <kbd>Enter</kbd> key pressed after each entry, since fields are exposed based on the value entered.  So based on the solution <a href="https://stackoverflow.com/questions/10243153/press-enter-key-in-selenium">here</a>, I've been trying different ways to enter a string into the form and press <kbd>Enter</kbd> - here are the ones that I've tried:</p>
  
  <pre><code>// type field value
  selenium.type("program", "MIC HOMEOWNERS");
  
  // ** not working: selenium.keyPress("program", "\\13");
  // ** not working: selenium.select("program", "Program");
  // ** not working: selenium.keyPressNative(Keys.ENTER.toString());
  // ** not working: selenium.keyDown("program", "13");
  </code></pre>
  
  <p>It would <em>seem</em> like this is the most logical solution (<code>selenium.keyPressNative(Keys.ENTER)</code>), but the compiler throws an error if you don't add the <code>.toString</code>, since <code>keyPressNative</code> is expecting a String.</p>
  
  <p>The actual form code:</p>
  
  <pre><code>&lt;label  &gt;Program&lt;/label&gt; 
      &lt;input id="program" name="program1" class="readonly-bg" readonly="readonly" type="text" value="MIC HOMEOWNERS" size="12"/&gt;
      &lt;input id="program" name="program" type="hidden" value="601"/&gt;
          &lt;script type="text/javascript"&gt;  
              Spring.addDecoration(new Spring.ElementDecoration({  
                  elementId : "program",  
                  widgetType : "dijit.form.ValidationTextBox",  
                  widgetAttrs : { 
                      trim:true ,
                      required : true
                  }}));  
          &lt;/script&gt;
  &lt;br&gt;
  </code></pre>
  
  <p>How do I emulate the press of the <kbd>Enter</kbd> key?</p>