title: How can I consistently remove the default text from an input element with Selenium?
body: <p>I'm trying to use Selenium WebDriver to input text to a GWT input element that has default text, "Enter User ID".  Here are a few ways I've tried to get this to work:</p>
  
  <pre><code>        searchField.click();
          if(!searchField.getAttribute("value").isEmpty()) {
              // clear field, if not already empty 
              searchField.clear();
          }
          if(!searchField.getAttribute("value").isEmpty()) {
              // if it still didn't clear, click away and click back
              externalLinksHeader.click();
              searchField.click();
          }
  
          searchField.sendKeys(username);
  </code></pre>
  
  <p>The strange thing is the above this only works some of the time.  Sometimes, it ends up searching for "Enter User IDus", basically beginning to type "username" after the default text -- and not even finishing that.</p>
  
  <p>Any other better, more reliable ways to clear out default text from a GWT element?</p>
  
  <p><strong>Edited to add:</strong> The HTML of the input element.  Unfortunately, there's not much to see, thanks to the JS/GWT hotness.  Here's the field when it's unselected:</p>
  
  <pre><code>&lt;input type="text" class="gwt-TextBox empty" maxlength="40"&gt;
  </code></pre>
  
  <p>After I've clicked it and given it focus manually, the default text and the "empty" class are removed.</p>
  
  <p>The JS to <code>setDefaultText()</code> gets called both <code>onBlur()</code> and <code>onChange()</code> if the change results in an empty text field.  Guess that's why the <code>searchField.clear()</code> isn't helping.</p>
  
  <p>I've also stepped through this method in debug mode, and in that case, it never works.  When run normally, it works the majority of the time.  I can't say why, though.</p>