title: How can I check the checkbox state using Selenium?
body: <p>How can I verify if a checkbox is checked or unchecked using Selenium?</p>
  <p>Because method &quot;<strong>element.Selected</strong>&quot; does not work in this case.</p>
  <p>Here is the HTML code if a checkbox is checked:</p>
  <pre><code>&lt;td class=&quot;dxgvCommandColumn_MetropolisBlue dxgv&quot; onclick=&quot;aspxGVScheduleCommand('messageGrid',['Select',1],1)&quot; align=&quot;center&quot;&gt;
      &lt;span id=&quot;messageGrid_DXSelBtn1_D&quot; class=&quot;dxICheckBox_MetropolisBlue dxichSys dxWeb_edtCheckBoxChecked_MetropolisBlue&quot;&gt;
          &lt;input id=&quot;messageGrid_DXSelBtn1&quot; value=&quot;U&quot; readonly=&quot;readonly&quot; style=&quot;border-width:0;width:0;height:0;padding:0;margin:0;position:relative;background-color:transparent;display:block;&quot; type=&quot;text&quot;/&gt;
      &lt;/span&gt;
  &lt;/td&gt;
  </code></pre>
  <p>Here is the HTML code if a checkbox is unchecked:</p>
  <pre><code>&lt;td class=&quot;dxgvCommandColumn_MetropolisBlue dxgv&quot; onclick=&quot;aspxGVScheduleCommand('messageGrid',['Select',1],1)&quot; align=&quot;center&quot;&gt;
      &lt;span id=&quot;messageGrid_DXSelBtn1_D&quot; class=&quot;dxWeb_edtCheckBoxUnchecked_MetropolisBlue dxICheckBox_MetropolisBlue dxichSys&quot;&gt;
          &lt;input id=&quot;messageGrid_DXSelBtn1&quot; value=&quot;U&quot; readonly=&quot;readonly&quot; style=&quot;border-width:0;width:0;height:0;padding:0;margin:0;position:relative;background-color:transparent;display:block;&quot; type=&quot;text&quot;/&gt;
      &lt;/span&gt;
  &lt;/td&gt;
  </code></pre>
  <p>Image:</p>
  <p><a href="https://i.stack.imgur.com/SgFJp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SgFJp.png" alt="Checkboxes" /></a></p>