I'm working on some research issue which requires me to acquire the exact stack trace when certain JavaScript alters DOM tree.
I managed to achieve satisfactory result using MutationObserver combined with console.trace API(sample code is shown below)within Chrome browser, but when I tried to automate this process with selenium webdriver, the extracted log does not contains any stack trace information.
var callback = function(mutationsList) {
mutationsList.forEach(function (mutation) {
switch(mutation.type) {
case "attributes":
var rect = mutation.target.getBoundingClientRect();
console.log(JSON.stringify(rect));
console.trace();
break;
}
});
};
new MutationObserver(callback).observe(node, {
attributes: true,
childList: true
});
I also tried to substitute console.trace() API with Error.stack, but within the callback defined by MutationObserver, the outputed stack trace is completely different from that generated by console.trace().
Is there any proper way to get the correct stack trace from chrome to selemium?