I have seen this solution for getting all attributes with protractor:
Get all element attributes using protractor
But I am using typescript with Angular 6 and cannot seem to extend it with the above method.
What I am doing is this:
import {browser, by, element} from 'protractor';
element.prototype.getAttributes = function () {
return (function (node) {
let attrs = {};
for (let i = 0; i < node.length; i++) {
attrs[node.item(i).name] = node.item(i).value;
}
return attrs;
})(this.attributes);
};
And I am getting the following error:
Unhandled rejection TypeError: Cannot set property 'getAttributes' of undefined
Get attribute works fine, but has the following message:
W/element - more than one element found for locator By(css selector, #id) - the first result will be used
I would still like to stick with imports rather than switching to require for modules.
How can I fix this and make it work for Typescript?