title: can't verify selected checkbox, Selenium Webdriver Java
body: <p>In my test I want to verify selected checkbox. Below is my code</p>
  
  <pre><code>if (CheckboxForFirstCitizenship.isSelected()) {
          System.out.println("Checkbox selected");
      } else {
          System.out.println("Checkbox not selected");
      }
      if (CheckboxForSecondCitizenship.isSelected()) {
          System.out.println("Checkbox selected");
      } else {
          System.out.println("Checkbox not selected");
      }
  </code></pre>
  
  <p>Web elements I have in PageObjects class</p>
  
  <pre><code>@FindBy(xpath = "/html[1]/body[1]/ufe-root[1]/div[1]/div[1]/div[1]/ng-component[1]/div[1]/ufe-klient[1]/app-dashboard[1]/main[1]/div[1]/div[2]/app-individual-client-edit-container[1]/app-process-container[1]/app-local-loader[1]/div[1]/div[3]/app-individual-client-edit-client-data[1]/app-form-container[1]/p-accordion[1]/div[1]/p-accordiontab[1]/div[2]/div[1]/div[2]/div[1]/app-form-data-set-container[1]/div[1]/div[1]/app-individual-client-edit-personal-data-form[1]/app-data-container[1]/div[1]/div[2]/app-container-state[1]/div[1]/form[1]/div[1]/div[8]/div[1]/div[1]/app-individual-client-edit-citizenship-form[1]/div[2]/p-checkbox[1]/div[1]/div[2]")
  @CacheLookup
  public WebElement CheckboxForFirstCitizenship;
  
  @FindBy(xpath = "/html[1]/body[1]/ufe-root[1]/div[1]/div[1]/div[1]/ng-component[1]/div[1]/ufe-klient[1]/app-dashboard[1]/main[1]/div[1]/div[2]/app-individual-client-edit-container[1]/app-process-container[1]/app-local-loader[1]/div[1]/div[3]/app-individual-client-edit-client-data[1]/app-form-container[1]/p-accordion[1]/div[1]/p-accordiontab[1]/div[2]/div[1]/div[2]/div[1]/app-form-data-set-container[1]/div[1]/div[1]/app-individual-client-edit-personal-data-form[1]/app-data-container[1]/div[1]/div[2]/app-container-state[1]/div[1]/form[1]/div[1]/div[8]/div[1]/div[2]/app-individual-client-edit-citizenship-form[1]/div[2]/p-checkbox[1]/label[1]")
  @CacheLookup
  public WebElement CheckboxForSecondCitizenship;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/C4KBF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C4KBF.png" alt="enter image description here"></a></p>
  
  <p>In test result I have two printlines 'Checkbox not selected' despite of firstCheckox is selected. What I'm doing wrong? Can someone help?</p>
  
  <pre><code>&lt;p-checkbox _ngcontent-c26="" binary="true" class="control__hint ng-untouched ng-pristine ng-valid ng-star-inserted" label="Główne" id="main-citizenship-checkbox-0" style="" xpath="1"&gt;
      &lt;div class="ui-chkbox ui-widget"&gt;
          &lt;div class="ui-helper-hidden-accessible"&gt;
              &lt;input type="checkbox" name="undefined" value="undefined"&gt;
          &lt;/div&gt;
          &lt;div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default ui-state-active"&gt;&lt;span class="ui-chkbox-icon ui-clickable pi pi-check"&gt;&lt;/span&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;!----&gt;
      &lt;label class="ui-chkbox-label ui-label-active ng-star-inserted"&gt;Główne&lt;/label&gt;
  &lt;/p-checkbox&gt;
  </code></pre>