Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

chore(types): Inherit from webdriver.WebDriver types #4016

Merged
merged 1 commit into from
Jan 30, 2017

Conversation

sjelin
Copy link
Contributor

@sjelin sjelin commented Jan 26, 2017

I decided to address this comment:

#4000 (comment)

While doing do I decided to take on this TODO:

// TODO: extend WebDriver from selenium-webdriver typings

One possible issue here is that ProtractorBrowser only copies over methods, so it doesn't actually
implement WebDriver's interface. This isn't a problem right now, since WebDriver's interface
only has functions on it. But it could be a problem in the future.

This is also weird in that browser instanceof webdriver.WebDriver is false but TypeScript probably thinks otherwise. An alternative option would be to do:

export class AbstractWebDriver {
  actions: typeof WebDriver.prototype.actions;
  call: typeof WebDriver.prototype.call;
  ...
}

Which would accomplish basically what the TODO suggested, but without ever actually inheriting from anyone

@@ -811,7 +738,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
* @returns {!webdriver.promise.Promise} A promise that will be resolved to
* the located {@link webdriver.WebElement}.
*/
findElement(locator: Locator): WebElement {
findElement(locator: Locator): WebElementPromise {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been WebElementPromise the whole time

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should fix the JSDoc @returns to reflect the same return type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -811,7 +738,7 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
* @returns {!webdriver.promise.Promise} A promise that will be resolved to
* the located {@link webdriver.WebElement}.
*/
findElement(locator: Locator): WebElement {
findElement(locator: Locator): WebElementPromise {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should fix the JSDoc @returns to reflect the same return type.

I decided to address this comment:

angular#4000 (comment)

While doing do I decided to take on this TODO:

https://github.com/angular/protractor/blob/ccf02ab5f1070f0d7124318dc0099252f3c747e2/lib/browser.ts#L38

One possible issue here is that `ProtractorBrowser` only copies over methods, so it doesn't actually
implement `WebDriver`'s interface.  This isn't a problem right now, since `WebDriver`'s interface
only has functions on it.  But it could be a problem in the future.
@sjelin sjelin merged commit 46a1e0c into angular:master Jan 30, 2017
igniteram pushed a commit to igniteram/protractor that referenced this pull request Feb 21, 2017
I decided to address this comment:

angular#4000 (comment)

While doing do I decided to take on this TODO:

https://github.com/angular/protractor/blob/ccf02ab5f1070f0d7124318dc0099252f3c747e2/lib/browser.ts#L38

One possible issue here is that `ProtractorBrowser` only copies over methods, so it doesn't actually
implement `WebDriver`'s interface.  This isn't a problem right now, since `WebDriver`'s interface
only has functions on it.  But it could be a problem in the future.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants