Search code examples
javascriptjquerydomxpathfirepath

How does firepath finds unique xpath on click


I am very curious to know how does firepath finds a unique xpath locator with in seconds as soon as we click on element. I know how to query xpath using firepath, but what I want to know that which language or technology has been used to developed such tools and what if I have to develop similar kind of tool. I have seen many automation tool have develop with such tools where when we click on page it will generate unique xpath locator, it makes me to curious and I want to know in depth how does things works in back end.

  1. When I open DOM in developer tool it was so confusing.
  2. How they identify element on click?
  3. Is it rocket science?
  4. Do they user JavaScript, JQuery or any other programing language?
  5. Do we have any apis which can be use?

Solution

  • type this in console and click somewhere) so it's the answer

    document.addEventListener('click', function(event){console.log(event.target)});