Internet explorer selenium:Concat xpath函数在internet explorer中不起作用

Internet explorer selenium:Concat xpath函数在internet explorer中不起作用,internet-explorer,selenium,xpath,concat,Internet Explorer,Selenium,Xpath,Concat,我在Internet Explorer 10中执行和xpath函数时遇到问题。它在Firefox甚至Chrome上都能完美运行,但在IE上却失败了。我需要搜索以下错误消息: We cannot find this car, please click on "I don't know my car reg" above 此消息的问题是双引号和“请勿”上的引号 无法使用: //span[@id='id']//*[text()='We cannot find this car, please cli

我在Internet Explorer 10中执行和xpath函数时遇到问题。它在Firefox甚至Chrome上都能完美运行,但在IE上却失败了。我需要搜索以下错误消息:

We cannot find this car, please click on "I don't know my car reg" above
此消息的问题是双引号和“请勿”上的引号

无法使用:

//span[@id='id']//*[text()='We cannot find this car, please click on "I don't know my car reg" above']

所以我试了一下:

//span[@id='id']//*[text()=concat('We cannot find this car, please click on "I don',"'",'t know my car reg" above')]'
concat功能在chrome和fiferox中运行完美,但在IE中我得到了以下例外:

org.openqa.selenium.InvalidSelectorException: The xpath expression '//span[@id='quoteForm:registrationLookupPart:m1']//*[text()=concat('We cannot find this car, please click on "I don',"'",'t know my car reg" above')]' cannot be evaluated or does notresult in a WebElement (WARNING: The server did not provide any stacktrace information)
有人知道为什么Selenium IE驱动程序抛出此异常吗

它看起来像concat函数,或者IE不存在,或者工作方式不同。这是真的吗


非常感谢

IE没有提供本机xpath实现,因此selenium必须提供自己的实现,这很可能是它遇到的情况之一。一般的建议是,如果不必使用xpath,就不要使用xpath,而是使用css选择器,因为这会更快。我不确定这是否可行,因为您尚未发布html。

有几个选项:

在XPath中使用部分文本匹配:

//*[contains(text(), "We cannot find this car, please click on")]
按类名查找元素:

findElement.ByClass("rich-message-label");

下面是html代码。在这种情况下可以使用css定位器吗

我们找不到这辆车,请单击上面的“我不知道我的汽车注册号”

findElement.ByClass("rich-message-label");