I want to capture the xpath of an element in IE11 through UFT.Is it possible?
Thanks in advance...
I want to capture the xpath of an element in IE11 through UFT.Is it possible?
Thanks in advance...
The problem is that there is no the XPath of an element, each element may have multiple XPaths (this is why UFT doesn't supply a default value for the XPath).
You can look for a JavaScript implementation (like the one in this answer) and then use Page.RunScript
to get an XPath for your selected element.
The problem is to pass the element to the JavaScript, one way you can use is via IE's `sourceIndex'.
something like this (untested code follows).
Browser("B").Page("P").RunScriptFromFile("C:\defineGetXPath.js")
SrcIndex = Browser("B").Page("P").WebElement("E").GetROProperty("source_index")
XPath =Browser("B").Page("P").RunScript( "getXPath(document.all[" & SrcIndex & "])" )