0

I've tried the following xpath but none of them work. The id is listed differently everytime. Next to the checkbox is this word " poetin alfa"

- //input[@type='checkbox'][@value='on']
- //*[@id='id1']
-//input[contains(text(),'<poetin alfa>')]/preceding-sibling::input[@type='checkbox']
- //input[contains(text(),'<poetin alfa>')]/following-sibling::input[@type='checkbox']
<span class="v-checkbox v-widget">
<input id="id1" type="checkbox" value="on" tabindex="0"/>
<label for="id1"/>
asked Jul 3, 2018 at 21:12
5
  • 2
    Where is that word in your example html? Commented Jul 3, 2018 at 22:31
  • <poetin alfa> are an other checkbox value ? Another tag with "poaetin alpha" as text ? In your XPath example, you seem to be looking for a tag into a text of another tag. Please provide full example of your HTML which containing the poetin alfa tag, it will be easier to help you Commented Jul 4, 2018 at 5:12
  • Please provide more info Commented Jul 4, 2018 at 5:16
  • Are your <span>, <input> and <label> all nested one inside the other? Please show more of your HTML. Commented Jul 4, 2018 at 10:17
  • The id alone should work since it's supposed to be unique, but I suspect that the HTML code you think is shown is not what is actually shown. You're searching for text in a label that does not appear to be in the label tag. I would think a proper label would be <label for="id1">poetin alfa</label> or if it really does have ankle brackets <label for="id1">&lt;poetin alfa&gt;</label> Commented Jul 5, 2018 at 13:08

1 Answer 1

2

Try with the below xpath.

//input[contains(text(),'poetin alfa')]/preceding-sibling::input[@type='checkbox']

As you didnt provide the html structure of the text (poetin alfa), I will go with your xpath. The xpath which you constructed has <>.

//input[contains(text(),'')]

You should remove the <> in contains text().

answered Jul 4, 2018 at 9:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.