title: selenium webdriver select element
body: <p>I have a select control on my site.  I am using page objects to interact with the page.  If I do (with the first 2 lines under my class and the <code>selectByValue</code> in my method)</p>
  
  <pre class="lang-java prettyprint-override"><code>@FindBy(id="foo")
  private Select foo;
  
  foo.selectByValue("myValue");
  </code></pre>
  
  <p>It fails with a null pointer.  I also tried without the <code>@FindBy</code>.</p>
  
  <p>Now if I do this in my method it all works fine and selects the correct item</p>
  
  <pre class="lang-java prettyprint-override"><code>Select foo = new Select(sDriver.findElement(By.id("foo")));
  foo.selectByValue("myValue");
  </code></pre>
  
  <p>Here is the actual web snippet for that control (edited to protect the innocent)</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;select id="foo" name="service_name"&gt;
      &lt;option selected="selected" value="one"&gt;one&lt;/option&gt;
      &lt;option value="two"&gt;two&lt;/option&gt;
      &lt;option value="three"&gt;three&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Let me say that I have a work around for my issue <strong>but</strong> I don't get why the "<em>normal</em>" path is not working. </p>