mercredi 5 janvier 2022

How I can find a checkbox element associated with a label

Im trying to create a xpath of a checkbox which has only label as unique identifier. The given Id or values change when a new checkbox element is created.

<li>
  <input type="checkbox" value="f052503c-28c2-4b2d-8bd3-0ef6cc0e563a" id="f052503c-28c2-4b2d- 
  8bd3-0ef6cc0e563a" name="ElementIds" class="i-checks" 
  checked="">
  <span class="m-l-xs"><label for="f052503c-28c2-4b2d-8bd3-0ef6cc0e563a">AuElement</label> 
  </span>
</li>

There are a couple of options i have tried so far but nothing is working:

CheckboxElement = //input[@type = 'checkbox' and @label = 'AuElement']
//input[@type='checkbox']//span[@label='AuElement']

For now I tried to use: //*[contains(text(), 'AuElement')] xpath but i cannot use if CheckboxElement.Selected() method to check if checkbox is already selected or not. Any help would be highly appreciated. Thanks




Aucun commentaire:

Enregistrer un commentaire