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

bish
8631 gold badge11 silver badges25 bronze badges
asked Aug 3, 2015 at 9:28
2
  • Can you paste some more html content 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')]
answered Aug 3, 2015 at 13:56
1
  • @saiviswanath - if the answer solved your problem, please mark it as accepted, then delete your comment. 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.

answered Aug 3, 2015 at 17:14
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')]
answered Aug 6, 2015 at 13:24

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.