(Web开发新手)
嗨,谁能解释我为什么
Object x=getCurrentPage().getByXPath("//div[@class = 'notification']
/text() =
'Product saved successfully'").get(0);
返回一个
Boolean false
对象,但这Object y = getCurrentPage().getByXPath("//div[@class='notification']
/text()").get(0);
返回带有数据
DomText
的Product saved successfully
对象?为什么是布尔
false
?在我看来,它应该返回true
。ps。当我在XPathBrowser(FF插件)中尝试相同的查询时,它返回
boolean:true
非常感谢
最佳答案
使用:
//div[@class='notification']/text()[ . = 'Product saved successfully']
因为集合
//div[@class='notification']/text()
永远不会等于字符串“产品成功保存”。正如Alejandro&LarsH指出的(他们俩都是正确的),这个答案是完全错误的。关键不是
//div[@class = 'notification']/text() = 'Product saved successfully'
不起作用,只是.get(0)
在第一个选项返回的布尔值上没有意义(它只是声明true
,如“该节点存在”)