protractor
protractor copied to clipboard
Fix: Now correctly allows to override ElementFinder and ElementArrayFinder methods
Fix: Now correctly allows to override ElementFinder and ElementArrayFinder methods
Monkey-patching was done in ElementFinder constructor against 'this'. It means this monkey-patching is applied AFTER all methods in inherited objects declared - it will just replace them. Here is list of WebElement methods, that is monkey-patched into ElementFinder: let WEB_ELEMENT_FUNCTIONS = [ 'click', 'sendKeys', 'getTagName', 'getCssValue', 'getAttribute', 'getText', 'getRect', 'isEnabled', 'isSelected', 'submit', 'clear', 'isDisplayed', 'getId', 'takeScreenshot' ];
class Component extends ElementFinder {
constructor(elementFinder: ElementFinder) {
super(elementFinder.browser_, elementFinder.elementArrayFinder_);
}
async click() {
console.log('OWN click!')
await super.click()
}
}
new Component($('button')).click()
Before this PR code above would not be working - since monkey-patching is overrides methods declared in child classes:
https://github.com/Xotabu4/protractor-element-extend/issues/20
@cnishina could you take a look at it useful PR? :)