'Have a problem to click on checkbox (xPath complex structure)

I have a problem and tried many thing (following-sibling, following etc) but couldn't resolve this. So I have this structure:

<li>
 <span>
  <span>
   <input type="checkbox">
  </span>
 </span>
 <div>
  <span>
   <span>Customer</span>
  </span>
 </div>
</li>

I have like a checkboxes and I wanna locate on checkbox and click on it where text() attribute is Customer.



Solution 1:[1]

The XPath to locate checkbox input based on "Customer" text in such XML structure could be:

"//li[.//span[text()='Customer']]//input[@type='checkbox']"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Prophet