1

I need to use Selenium Java to click on some links based on another element in the same line. I have the following HTML:

HTML image

I need to click on the span link (red color) of every line which contains that empty checkbox (green color). I can find all empty checkboxes by using xpath //img[contains(@src,'completion-auto-n')], but I can't find a XPATH to click on these span based on the checkbox's values.

1
  • 1
    Don't post pictures of code, post the actual HTML. It is fine to include the image and drawing to supplement the description, but if you want people to help you with XPath, it is much easier for them to copy/paste the HTML and work on a solution. You are more likely to get help if you make it easy for us to help you. Commented Dec 4, 2020 at 22:17

1 Answer 1

0

From the img elements, you could use the ancestor:: axis with a predicate to look up the tree for the first div, and then look down the tree with the // descendant axis from that div for an span that is a child of an a:

//img[contains(@src,'completion-auto-n')]/ancestor::div[1]//a/span
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.