My code:

<input type="text"
       class="other[] form-control"

Where name projectsurvey[changes][choosekey][changes]

I'm using this to try to find the item: xpath("//*[starts-with(@name,'projectsurvey','choosekey')])

The firebug xpath is showing like this :


and the firebug xpath changes:


How do I find this element by xpath

Is there any other way to find this element

  • Can you paste some more html content
    – QAMember
    Aug 3, 2015 at 13:28
  • Everything in name="" is getting changed? Aug 4, 2015 at 12:15

3 Answers 3


You can use 'contains' :

//input[contains(@name, 'projectsurvey[143') and contains(@name, 'choosekey][143')]
  • @saiviswanath - if the answer solved your problem, please mark it as accepted, then delete your comment.
    – Kate Paulk
    Jun 5, 2017 at 11:41

I had more complicated situation, even 'contains' was not enough. I got list of all elements of type (find by TAG_NAME), then looped over the list to find elements of interest by parts of id and class name. I had even to find matching pairs of elements with parts of name generated dynamically.

Because of flexible list processing in Python, it was not too hard. I try to avoid XPATH: real programming language like Python, which I already know, gives me more flexibility and is easier to maintain, than cryptic and obscure XPATH expressions. YMMV.


Depending on how many more similar elements you have on the page, an xpath like the following may do what you need:


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.