What is the difference between .// and //* in XPath?

后端 未结 4 1772
梦如初夏
梦如初夏 2020-11-22 10:39

While finding the relative XPath via Firebug : it creates like

  1. .//*[@id=\'Passwd\']--------- what if we dont use dot at the start what it sign

4条回答
  •  不知归路
    2020-11-22 11:23

    The dot in XPath is called a "context item expression". If you put a dot at the beginning of the expression, it would make it context-specific. In other words, it would search the element with id="Passwd" in the context of the node on which you are calling the "find element by XPath" method.

    The * in the .//*[@id='Passwd'] helps to match any element with id='Passwd'.

提交回复
热议问题