带有法语特殊字符 (è d') 的无效 XPath



如果 XPath 包含法语特殊字符(è d'(,似乎无法正常工作,得到以下错误

InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression 
//*[@class='v-menubar-menuitem']/*[contains(text(), 'Afficher la bibliothèque d'autorisations')] 
because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': 
The string '//*[@class='v-menubar-menuitem']/*[contains(text(), 'Afficher la bibliothèque d'autorisations')]' is not a valid XPath expression.

运行Windows机器,更改了EOL(UTF-8,基于Unix(也用于文件,但不起作用。

当我们在英语本地化中运行时,这工作正常

在 XPath 中使用è字符没有错。

另一方面,d'不是单个字符,而是一个后跟单引号'd,并且单引号干扰了在 XPath 中用作字符串分隔符的单引号。

如果将字符串分隔符更改为使用双引号,则内部单引号不会有问题:

//*[@class='v-menubar-menuitem']
/*[contains(text(), "Afficher la bibliothèque d'autorisations")]

最新更新