title: Does Selenium's "sendKeys" method perform a "click" on the targeted element first?
body: <p>I'm currently writing cucumber tests for widgets that will be (and are) implemented in different technologies (different web frameworks, Java Swing [not really, but it should technically be possible], etc). The tests are intended to describe the functionality of the widget under test, by directly emulating the input of a user. For example, a test could be phrased as something like "the user opens webpage X, then clicks there, then there, then there, and now I expect this textfield to contain the value Y".</p>
  
  <p>The technology I'm currently implementing the tests in is the web, using Selenium.</p>
  
  <p>Now, assuming a user wants to type something into a textfield, what the user would do in reality is click into the textfield and then start typing. On its own, typing on your keyboard doesn't have anything to do with the textfield - only because the click switched the focus to the textfield does the textfield receive the keyboard input.</p>
  
  <p>Now, Selenium has a <code>sendKeys</code> method. What does this method do, precisely? The javadoc states "Use this method to simulate typing into an element, which may set its value".</p>
  
  <p><strong>Does the <code>sendKeys</code> method emulate a click (as if <code>.click</code> was called first) and then keyboard input, as a real user would? Or does it set the focus and then starts typing? Or does it circumvent focus altogether and simply sends "keyboard input" to the input element?</strong></p>
  
  <p>As certain widgets might exhibit special behavior if clicked, I need to know if Selenium performs a click under the hood, or if I manually have to call it in order to realistically emulate the user's behaviour.</p>
  
  <p><sub><sub>Note: I have not added cucumber to the tags as it is, although relevant for context, only tangential to the actual question</sub></sub></p>