Reputation: 1904
I have been given a requirement to log all actions that protractor. Something along the lines of
console.log(action + " was called with arguments " + args.join(", ");
My first effort was to wrap the globally available browser.driver in a Proxy object then use this proxied object in my tests, and log the action before passing the call on to the target. This works for methods such as "get" however this does not seem to capture events such as click, and sendKeys. I tried wrapping the globally available element function in a Proxy as well however this didn't work and only seemed to randomly output the "all" method being called.
Is there an easy way to log the webdriver actions which are called?
Upvotes: 1
Views: 570
Reputation: 136
In case you are interested to create custom reporter. You can create a wrapper function for every event.
Please refer below example for click():
module.exports = {
Click: function (elem, logName) {
elem.click().then(function () {
customReporter.addResult('Performed click for ' + logName);
}, function (err) {
customReporter.addResult('Failed to click on "' + logName + '" due to "' + err.message + '"');
expect(false).toBe(true);
});
},
};
logName - is a name passed which can be shown in report.
With this approach, you can record all your actions in some file.
Upvotes: 1