[英]what is the difference between “//div[.//a[text()='SELENIUM']]” and “//div[//a[text()='SELENIUM']]” in selenium xpath
what is the difference between "//div[.//a[text()='SELENIUM']]" and "//div[//a[text()='SELENIUM']]" in selenium xpath. 在selenium xpath中“//div [.// [text()='Selenium']]”和“// div [// a [text()='SELENIUM']]”之间有什么区别?
Can some one please clarify my query on xpath, what is the difference when i give dot(.) before //a and without dot(.) .//a 有人可以澄清我对xpath的查询,当我在// a之前给出点(。)而没有点(。)时,有什么区别.//a
you can use the above mentioned xpath's in this url " http://demo.guru99.com/selenium/guru99home/ " to see the difference. 你可以在这个网址“ http://demo.guru99.com/selenium/guru99home/ ”中使用上面提到的xpath来查看差异。
//x
searches the whole tree //x
搜索整个树
.//x
searches the subtree under the context node .//x
搜索上下文节点下的子树
So in a predicate, //div[//x]
selects a div
if there is an x
anywhere in the document, while //div[.//x]
selects a div
if there is an x
within the subtree rooted at that div
. 所以在一个谓词中,
//div[//x]
选择一个div
如果文档中有一个x
,而//div[//x]
//div[.//x]
选择一个div
如果在该子树中有一个x
div
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.