title: How to use Selenium to enter a tab character into a textarea?
body: <p>I'm using Selenium Web Driver (Java, Chrome Browser). I would like to enter a tab character into a text area. By default, entering a tab character causes the next input to be focused, but I actually want the tab character to be printed into the <em>textarea</em> input.</p>
  
  <p>Since my tests are running on a windows machine, I thought I could use the alt-code to enter the tab. IE</p>
  
  <ol>
  <li>Hold alt</li>
  <li>Press 0 </li>
  <li>Press 9 </li>
  <li>Release alt</li>
  </ol>
  
  <p>But I'm not sure how to do this programmatically with <em>WebDriver</em>. I tried the following:</p>
  
  <pre><code>WebElement myTextArea = driver.findElement(By.cssSelector("form textarea"));
  
  myTextArea.sendKeys("before_tab", Keys.chord(Keys.ALT, Keys.NUMPAD0, Keys.NUMPAD9), "after_tab");
  </code></pre>
  
  <p>...but it just printed "before_tabafter_tab" into the text area, I guess because it's pressing ALT, 0, and 9 all at the same time which doesn't translate to a printable character.</p>
  
  <p>I would also consider pasting either via keyboard shortcut or context menu (this is actually closer to how I expect the user to enter text into the <em>textarea</em>), but I can't see how to put the text onto the clipboard for the selenium-driven browser to access.</p>
  
  <p>Any help would be appreciated.</p>