This repository was 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
chore(types): add in types inherited from selenium-webdriver #3288
Merged
Merged
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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -14,6 +14,32 @@ let WEB_ELEMENT_FUNCTIONS = [ | |
'serialize', 'takeScreenshot' | ||
]; | ||
|
||
// Explicitly define webdriver.WebElement. | ||
export class WebdriverWebElement { | ||
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. Would it make more sense for these to be interfaces instead of classes? 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. Changing this to be an interface. |
||
getDriver: () => webdriver.WebDriver; | ||
getId: () => webdriver.promise.Promise; | ||
getRawId: () => webdriver.promise.Promise; | ||
serialize: () => webdriver.promise.Promise; | ||
findElement: (subLocator: Locator) => webdriver.promise.Promise; | ||
click: () => webdriver.promise.Promise; | ||
sendKeys: (...args: (string|webdriver.promise.Promise)[]) => | ||
webdriver.promise.Promise; | ||
getTagName: () => webdriver.promise.Promise; | ||
getCssValue: (cssStyleProperty: string) => webdriver.promise.Promise; | ||
getAttribute: (attributeName: string) => webdriver.promise.Promise; | ||
getText: () => webdriver.promise.Promise; | ||
getSize: () => webdriver.promise.Promise; | ||
getLocation: () => webdriver.promise.Promise; | ||
isEnabled: () => webdriver.promise.Promise; | ||
isSelected: () => webdriver.promise.Promise; | ||
submit: () => webdriver.promise.Promise; | ||
clear: () => webdriver.promise.Promise; | ||
isDisplayed: () => webdriver.promise.Promise; | ||
takeScreenshot: (opt_scroll?: boolean) => webdriver.promise.Promise; | ||
getOuterHtml: () => webdriver.promise.Promise; | ||
getInnerHtml: () => webdriver.promise.Promise; | ||
} | ||
|
||
/** | ||
* ElementArrayFinder is used for operations on an array of elements (as opposed | ||
* to a single element). | ||
|
@@ -67,13 +93,14 @@ let WEB_ELEMENT_FUNCTIONS = [ | |
* action result, or null if no action has been called. | ||
* @return {ElementArrayFinder} | ||
*/ | ||
export class ElementArrayFinder { | ||
export class ElementArrayFinder extends WebdriverWebElement { | ||
getWebElements: Function; | ||
|
||
constructor( | ||
private browser_: Browser, getWebElements?: Function, | ||
private locator_?: any, | ||
public actionResults_: webdriver.promise.Promise = null) { | ||
super(); | ||
this.getWebElements = getWebElements || null; | ||
|
||
// TODO(juliemr): might it be easier to combine this with our docs and just | ||
|
@@ -379,7 +406,7 @@ export class ElementArrayFinder { | |
* | ||
* @return {webdriver.Locator} | ||
*/ | ||
locator(): any { return this.locator_; } | ||
locator(): Locator { return this.locator_; } | ||
|
||
/** | ||
* Apply an action function to every element in the ElementArrayFinder, | ||
|
@@ -661,12 +688,14 @@ export class ElementArrayFinder { | |
* that this is branched from. | ||
* @return {ElementFinder} | ||
*/ | ||
export class ElementFinder { | ||
export class ElementFinder extends WebdriverWebElement { | ||
parentElementArrayFinder: ElementArrayFinder; | ||
elementArrayFinder_: ElementArrayFinder; | ||
then: Function = null; | ||
then: (fn: Function, errorFn: Function) => webdriver.promise.Promise = null; | ||
|
||
constructor(private browser_: Browser, elementArrayFinder: ElementArrayFinder) { | ||
constructor( | ||
private browser_: Browser, elementArrayFinder: ElementArrayFinder) { | ||
super(); | ||
if (!elementArrayFinder) { | ||
throw new Error('BUG: elementArrayFinder cannot be empty'); | ||
} | ||
|
@@ -680,6 +709,7 @@ export class ElementFinder { | |
* | ||
* @param {function(webdriver.promise.Promise)} fn Function which takes | ||
* the value of the underlying actionResult. | ||
* @param {function(Error)} errorFn | ||
* | ||
* @return {webdriver.promise.Promise} Promise which contains the results of | ||
* evaluating fn. | ||
|
@@ -731,10 +761,12 @@ export class ElementFinder { | |
}); | ||
} | ||
|
||
static fromWebElement_(ptor: any, webElem: any, locator: any): ElementFinder { | ||
static fromWebElement_( | ||
browser: Browser, webElem: webdriver.WebElement, | ||
locator: Locator): ElementFinder { | ||
let getWebElements = | ||
() => { return webdriver.promise.fulfilled([webElem]); }; | ||
return new ElementArrayFinder(ptor, getWebElements, locator) | ||
return new ElementArrayFinder(browser, getWebElements, locator) | ||
.toElementFinder_(); | ||
} | ||
|
||
|
@@ -802,7 +834,7 @@ export class ElementFinder { | |
* @param {webdriver.Locator} subLocator | ||
* @return {ElementArrayFinder} | ||
*/ | ||
all(subLocator: any): ElementArrayFinder { | ||
all(subLocator: Locator): ElementArrayFinder { | ||
return this.elementArrayFinder_.all(subLocator); | ||
} | ||
|
||
|
@@ -833,7 +865,7 @@ export class ElementFinder { | |
* @param {webdriver.Locator} subLocator | ||
* @return {ElementFinder} | ||
*/ | ||
element(subLocator: any): ElementFinder { | ||
element(subLocator: Locator): ElementFinder { | ||
return this.all(subLocator).toElementFinder_(); | ||
} | ||
|
||
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
They would usually start with
*
for multiline comments. (That didn't show up well, it's a space in front of the *)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.
This should be fine because I am trimming the line prior to testing if it starts with a
*
. This should capture the comments in the index.d.ts file.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.
Right you are.