user7242550
user7242550

Reputation: 261

Unable to find element using the following Xpath

I am trying to find the input type with statusid_103408 and with text() Draft

enter image description here

here is the xpath i am using, not sure where I am going wrong

//input[@name='statusid_103408' and contains(text(), 'Draft')]

Upvotes: 0

Views: 50

Answers (2)

Adam Funderburg
Adam Funderburg

Reputation: 406

The reason this xpath does not work is because the text of "Draft" is not actually a property of the input element. It is contained in the li element that is the parent. Therefore, your search is returning no results.

I suggest just using the name only in your xpath search (if it unique). If you definitely need the text in your search, you can search the li item's text first, then find your input, like so:

//li[text()='Draft']/input[@name='statusid_103408']

Upvotes: 1

Gopal
Gopal

Reputation: 306

Use Value it will work , because value is unique, text is not inside the input tag!

Upvotes: 1

Related Questions