0

My code:

<input type="text"
       placeholder="Label"
       class="other[] form-control"
       name="projectsurvey[1438590696705][choosekey][1438590696705][]" 
       value="">

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 :

*[@id="choice1438590696705"]/div/div[1]/div[2]/div/input

and the firebug xpath changes:

[@id="choice143......."]/div/div[1]/div[2]/div/input

How do I find this element by xpath

Is there any other way to find this element

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

3 Answers 3

1

You can use 'contains' :

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

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.

0

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

//input[@type='text'][contains(@class,'form-control')][contains(@name,'projectsurvey')]

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.