Reputation: 9455
I am doing some XPath related work where a user should click any DOM element and it's XPath should get generated. Currently I am using FirePath (Firebug extension), but I need to remove the process of copy-pasting the XPath from there (for automation purposes) and instead pass it to a JavaScript function when the XPath is generated after the click.
Is it possible at all? Can someone guide me in the right direction on how to accomplish this?
Upvotes: 0
Views: 403
Reputation: 9455
My solution was to modify the stopInspecting()
function of FirePath. Here's the related code:
stopInspecting: function(inspectingNode, cancelled) {
this.inspecting = false;
var latestXpath = getXPathFromNode(inspectingNode); // getting xpath
// in Firebug 1.7 the signature of this method changed
// before there was only on arg: cancelled.
if (!Firebug.Inspector._resolveInspectingPanelName) {
cancelled = inspectingNode;
}
if(cancelled) {
this.navigate(this.previousLocation);
this.fireSIMSBar.selector = this.previousSelector;
delete this.previousLocation;
delete this.previousSelector;
}
this.fireSIMSBar.reset();
this.fireSIMSBar.evaluate();
// Passing xpath to javascript function
var doc = Application.activeWindow.activeTab.document;
var win = doc.defaultView;
win.wrappedJSObject.myFunction(latestXpath);
}
},
Upvotes: 0
Reputation: 20095
I see two possibilities how to achieve that:
Upvotes: 1