0

Thank you for taking a look. I've been able to work out with starts-with for below source code but for some reason, the ends-with doesn't work

<input type="text" value="" name="email" style="background-color: rgb(248, 248, 248);"/>

//input[starts-with(@name,'ema')]- Works absoultelty fine

css=input[name*='ema']- Works fine

css=input[name$='ail'] - Works fine

//input[ends-with(@name,'ail')]- doesn't work

//input[ends-with(@.,'ail')]- doesn't work

I am using firepath 0.9.7.1.1 & also tried in version 1.0- no luck. Thanks in advance I've already tried Xpath "ends-with" does not work & it didn't help.

Community
  • 1
  • 1
nandesh kalyankar
  • 302
  • 1
  • 5
  • 23
  • 1
    Possible duplicate of [Xpath "ends-with" does not work](http://stackoverflow.com/questions/22436789/xpath-ends-with-does-not-work) – har07 Jul 11 '16 at 12:16
  • Please don't tell us that something "doesn't work". Tell us how it fails. – Michael Kay Jul 11 '16 at 13:45
  • so whats the error you getting. Are you sure your input has name which is ending exactly with 'ail' ? check if there is space after 'ail' – Vinod Jul 11 '16 at 14:07

2 Answers2

1

The ends-with() function requires XPath 2.0.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • Thank you for your response. I've tried this with xpath 2.0 & it doesn't work. Of my surpise, the `starts-with` function work but not `ends-with` @har07 I've already tried that approach prior posting this query. – nandesh kalyankar Jul 11 '16 at 13:50
  • 1
    Don't tell us it doesn't work, tell us exactly what you did and exactly how it fails. There are two possibilities: your XPath engine is not a (conformant) XPath 2.0 engine, or you called ends-with() incorrectly. If you told us how it failed, we would probably be able to eliminate one of these possibilities. – Michael Kay Jul 11 '16 at 23:05
0

Firepath only supports XPath 1.0. From FirePath description on Mozilla Add-ons page :

FirePath is a Firebug extension that adds a development tool to edit, inspect and generate XPath 1.0 expressions, CSS 3 selectors and JQuery selectors (Sizzle selector engine).

So you can not use ends-with() function with FirePath. As explained in the linked question, you need to resort to manual implementation of ends-with() function logic using XPath 1.0 supported functions i.e substring() and string-length() :

//input[substring(@name, string-length(@name) - string-length('ema') +1) = 'ema']
har07
  • 88,338
  • 12
  • 84
  • 137