When using XPath to end fuzzy matching, the following problems are encountered: // Input [ends with (@ ID, ‘W’)] cannot locate the element whose ID ends with W in the input tag. The error is as follows
SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘//input[ends-with(@id,’w’)]’ is not a valid XPath expression.
(Session info: chrome=94.0.4606.81)
After querying relevant data, it is found that the reason for the problem is: the ends with method is the syntax of XPath 2.0, while the browser only supports XPath 1.0, so the above problem occurs.
terms of settlement:
According to the great God, it can be replaced by the following method equivalent to ends with:
//input[substring(@id, string-length(@id) – string-length(‘w’) +1) = ‘w’]
The reference is as follows, and its link is: https://stackoverflow.com/questions/36053559/how-to-locate-dynamic-element-using-xpathends-with-function-not-working