how to select label & input at same level

Ask general questions here.
rk325
Posts: 23
Joined: Mon Mar 27, 2023 6:02 pm

how to select label & input at same level

Post by rk325 » Thu May 11, 2023 9:44 pm

I have paths definition for a checkboxes that end at the same level for both, the input and its label:
div[1]/div[4]/tag/div/div/div/div[1]/div[3]/tag/div/div[2]/div[1]/input[@type='checkbox']
div[1]/div[4]/tag/div/div/div/div[1]/div[3]/tag/div/div[2]/div[1]/label[@innertext='Pool']

more lines for other 6 checkboxes with different labels follow.

I know I can select a label by redefining its path as: //label[@innertext='Pool']
I could do the same with its checkbox: //input[@type='checkbox']

The problem is that there are more combinations of input & label, label with unique innertext values, but their checkboxes would look identical: //input[@type='checkbox']

Is there any way I can select an input[@type='checkbox'] that corresponds to label[@innertext='Pool'] ?
Thanks,