org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression //a[Contains(Text(),'Forgot Password?')] because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//a[Contains(Text(),'Forgot Password?')]' is not a valid XPath expression.
最佳答案
错误说明了一切,您的xPath表达式无效。您不能将预定义关键字(例如text())更改为Text()。尝试//a[contains(text(),'Forgot Password')]
或//a[contains(.,'Forgot Password')]
有关InvalidSelectorException的更多信息,请参考this。
关于selenium - 使用与在1个匹配节点的firepath中正常工作的xpath定位元素时获取InvalidSelectorException,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54211296/