title: Asserting a checkbox is not checked by default in WebDriver with Junit
body: <p>I'm using WebDriver with Junit 4.11 and I want to assert that a checkbox is not selected by default, and to do that I'm unsure which constructor method to choose.</p>
  
  <p>The following is from the DOM before the checkbox is selected:</p>
  
  <pre><code>&lt;input type="checkbox" id="c234" name="instantAd" value="true" class="t-checkbox-A"&gt;
  </code></pre>
  
  <p>Then, once the checkbox becomes selected a 'checked' is added, like so:</p>
  
  <pre><code>&lt;input type="checkbox" id="c234" name="instantAd" value="true" checked="" class="t-checkbox-A"&gt;
  </code></pre>
  
  <p>I have tried the following:</p>
  
  <pre><code>WebElement checkBox = chrome.findElement(By.cssSelector("input.t-checkbox-A[name=\"instantAd\"]"));
  
      new WebDriverWait(chrome, 5).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input.t-checkbox-A[name=\"instantAd\"]")));
  
      Assert.assertEquals("null",checkBox.getAttribute("checked"));
  
      checkBox.click();
  
      Assert.assertEquals("true",checkBox.getAttribute("checked"));
  </code></pre>
  
  <p>The first assertion fails. Perhaps this is because the 'checked' attribute isn't visible in the DOM yet, at a guess.</p>
  
  <p>The stacktrace is displaying:</p>
  
  <blockquote>
    <p>java.lang.AssertionError: expected: java.lang.String but was: null</p>
  </blockquote>
  
  <p>I've searched many different posts but none offer me the answer Im looking for, and when checking <a href="http://junit.sourceforge.net/javadoc/org/junit/Assert.html" rel="nofollow">http://junit.sourceforge.net/javadoc/org/junit/Assert.html</a> for info and guidance (as being new to test automation, Im finding it difficult to work out what I need in my constructor.</p>
  
  <p>Any help would be most appreciated.</p>