This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix: Now correctly allows to override ElementFinder and ElementArrayFinder methods #5328
Open
Xotabu4
wants to merge
2
commits into
angular:master
Choose a base branch
from
Xotabu4:fix-elementfinder-elementarrayfinder-extension
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,17 +80,6 @@ export class ElementArrayFinder extends WebdriverWebElement { | |
public browser_: ProtractorBrowser, public getWebElements: () => Promise<WebElement[]> = null, | ||
public locator_?: any, public actionResults_: Promise<any> = null) { | ||
super(); | ||
|
||
// TODO(juliemr): might it be easier to combine this with our docs and just | ||
// wrap each one explicity with its own documentation? | ||
WEB_ELEMENT_FUNCTIONS.forEach((fnName: string) => { | ||
this[fnName] = (...args: any[]) => { | ||
let actionFn = (webElem: any) => { | ||
return webElem[fnName].apply(webElem, args); | ||
}; | ||
return this.applyAction_(actionFn); | ||
}; | ||
}); | ||
} | ||
|
||
/** | ||
|
@@ -730,6 +719,16 @@ export class ElementArrayFinder extends WebdriverWebElement { | |
return this.applyAction_(allowAnimationsTestFn); | ||
} | ||
} | ||
// TODO(juliemr): might it be easier to combine this with our docs and just | ||
// wrap each one explicity with its own documentation? | ||
WEB_ELEMENT_FUNCTIONS.forEach((fnName) => { | ||
ElementArrayFinder.prototype[fnName] = function (...args: any[]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you need here |
||
let actionFn = (webElem: any) => { | ||
return webElem[fnName].apply(webElem, args); | ||
}; | ||
return this.applyAction_(actionFn); | ||
}; | ||
}); | ||
|
||
/** | ||
* The ElementFinder simply represents a single element of an | ||
|
@@ -827,14 +826,6 @@ export class ElementFinder extends WebdriverWebElement { | |
this.elementArrayFinder_ = new ElementArrayFinder( | ||
this.browser_, getWebElements, elementArrayFinder.locator(), | ||
elementArrayFinder.actionResults_); | ||
|
||
WEB_ELEMENT_FUNCTIONS.forEach((fnName: string) => { | ||
(this)[fnName] = (...args: any[]) => { | ||
return (this.elementArrayFinder_)[fnName] | ||
.apply(this.elementArrayFinder_, args) | ||
.toElementFinder_(); | ||
}; | ||
}); | ||
} | ||
|
||
static fromWebElement_(browser: ProtractorBrowser, webElem: WebElement, locator?: Locator): | ||
|
@@ -1132,6 +1123,13 @@ export class ElementFinder extends WebdriverWebElement { | |
return a.getDriver().executeScript('return arguments[0] === arguments[1]', a, b); | ||
} | ||
} | ||
WEB_ELEMENT_FUNCTIONS.forEach((fnName) => { | ||
(ElementFinder.prototype)[fnName] = function (...args: any[]) { | ||
return (this.elementArrayFinder_)[fnName] | ||
.apply(this.elementArrayFinder_, args) | ||
.toElementFinder_(); | ||
}; | ||
}); | ||
|
||
/** | ||
* Shortcut for querying the document directly with css. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if
fnName
can be onlystring
you could add this type