title: How can I select checkboxes using the Selenium Java WebDriver?
body: <p>How can I check the checkboxes using an id or XPath expression? Is there a method similar to select by visibletext for a dropdown?</p>
  <p>Going through the examples given for all other related questions, I could not find a proper solution that works in a concise way that by few line or method I can check a chekbox or radio button.</p>
  <p>A sample HTML section is below:</p>
  <pre><code>&lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;
              &lt;span class=&quot;120927&quot;&gt;
              &lt;input id=&quot;ctl00_CM_ctl01_chkOptions_0&quot; type=&quot;checkbox&quot; name=&quot;ctl00$CM$ctl01$chkOptions$0&quot;/&gt;
              &lt;label for=&quot;ctl00_CM_ctl01_chkOptions_0&quot;&gt;housingmoves&lt;/label&gt;
              &lt;/span&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
          &lt;td&gt;
              &lt;span class=&quot;120928&quot;&gt;
              &lt;input id=&quot;ctl00_CM_ctl01_chkOptions_1&quot; type=&quot;checkbox&quot; name=&quot;ctl00$CM$ctl01$chkOptions$1&quot;/&gt;
              &lt;label for=&quot;ctl00_CM_ctl01_chkOptions_1&quot;&gt;Seaside &amp; Country Homes&lt;/label&gt;
              &lt;/span&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
  </code></pre>