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

chore(types): fixed types to use selenium-webdriver #3851

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 30 additions & 31 deletions lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ for (let foo in webdriver) {
exports[foo] = webdriver[foo];
}

// Explicitly define webdriver.WebDriver
// Explicitly define WebDriver
// TODO: extend WebDriver from selenium-webdriver typings
export class Webdriver {
actions: () => ActionSequence;
Expand Down Expand Up @@ -96,7 +96,7 @@ export interface ElementHelper extends Function {
*
* @private
* @param {Browser} browser A browser instance.
* @returns {function(webdriver.Locator): ElementFinder}
* @returns {function(Locator): ElementFinder}
*/
function buildElementHelper(browser: ProtractorBrowser): ElementHelper {
let element = ((locator: Locator) => {
Expand All @@ -114,8 +114,8 @@ function buildElementHelper(browser: ProtractorBrowser): ElementHelper {
/**
* @alias browser
* @constructor
* @extends {webdriver.WebDriver}
* @param {webdriver.WebDriver} webdriver
* @extends {WebDriver}
* @param {WebDriver} webdriver
* @param {string=} opt_baseUrl A base URL to run get requests against.
* @param {string=} opt_rootElement Selector element that has an ng-app in
* scope.
Expand All @@ -137,14 +137,14 @@ export class ProtractorBrowser extends Webdriver {
* The wrapped webdriver instance. Use this to interact with pages that do
* not contain Angular (such as a log-in screen).
*
* @type {webdriver.WebDriver}
* @type {WebDriver}
*/
driver: WebDriver;

/**
* Helper function for finding elements.
*
* @type {function(webdriver.Locator): ElementFinder}
* @type {function(Locator): ElementFinder}
*/
element: ElementHelper;

Expand Down Expand Up @@ -332,7 +332,7 @@ export class ProtractorBrowser extends Webdriver {
*
* Set by the runner.
*
* @returns {webdriver.promise.Promise} A promise which resolves to the
* @returns {wdpromise.Promise} A promise which resolves to the
* capabilities object.
*/
getProcessedConfig(): wdpromise.Promise<any> {
Expand Down Expand Up @@ -376,14 +376,14 @@ export class ProtractorBrowser extends Webdriver {
}

/**
* The same as {@code webdriver.WebDriver.prototype.executeScript},
* The same as {@code WebDriver.prototype.executeScript},
* but with a customized description for debugging.
*
* @private
* @param {!(string|Function)} script The script to execute.
* @param {string} description A description of the command for debugging.
* @param {...*} var_args The arguments to pass to the script.
* @returns {!webdriver.promise.Promise.<T>} A promise that will resolve to
* @returns {!wdpromise.Promise.<T>} A promise that will resolve to
* the scripts return value.
* @template T
*/
Expand All @@ -401,14 +401,14 @@ export class ProtractorBrowser extends Webdriver {
}

/**
* The same as {@code webdriver.WebDriver.prototype.executeAsyncScript},
* The same as {@code WebDriver.prototype.executeAsyncScript},
* but with a customized description for debugging.
*
* @private
* @param {!(string|Function)} script The script to execute.
* @param {string} description A description for debugging purposes.
* @param {...*} var_args The arguments to pass to the script.
* @returns {!webdriver.promise.Promise.<T>} A promise that will resolve to
* @returns {!wdpromise.Promise.<T>} A promise that will resolve to
* the
* scripts return value.
* @template T
Expand All @@ -433,7 +433,7 @@ export class ProtractorBrowser extends Webdriver {
*
* @param {string=} opt_description An optional description to be added
* to webdriver logs.
* @returns {!webdriver.promise.Promise} A promise that will resolve to the
* @returns {!wdpromise.Promise} A promise that will resolve to the
* scripts return value.
*/
waitForAngular(opt_description?: string): wdpromise.Promise<any> {
Expand Down Expand Up @@ -548,32 +548,31 @@ export class ProtractorBrowser extends Webdriver {

/**
* Waits for Angular to finish rendering before searching for elements.
* @see webdriver.WebDriver.findElement
* @returns {!webdriver.promise.Promise} A promise that will be resolved to
* the located {@link webdriver.WebElement}.
* @see WebDriver.findElement
* @returns {!wdpromise.Promise} A promise that will be resolved to
* the located {@link WebElement}.
*/
findElement(locator: Locator): WebElement {
return this.element(locator).getWebElement();
}

/**
* Waits for Angular to finish rendering before searching for elements.
* @see webdriver.WebDriver.findElements
* @returns {!webdriver.promise.Promise} A promise that will be resolved to an
* array of the located {@link webdriver.WebElement}s.
* @see WebDriver.findElements
* @returns {!wdpromise.Promise} A promise that will be resolved to an
* array of the located {@link WebElement}s.
*/
findElements(locator: Locator): webdriver.promise.Promise<any> {
findElements(locator: Locator): wdpromise.Promise<any> {
return this.element.all(locator).getWebElements();
}

/**
* Tests if an element is present on the page.
* @see webdriver.WebDriver.isElementPresent
* @returns {!webdriver.promise.Promise} A promise that will resolve to whether
* @see WebDriver.isElementPresent
* @returns {!wdpromise.Promise} A promise that will resolve to whether
* the element is present on the page.
*/
isElementPresent(locatorOrElement: ProtractorBy|
webdriver.WebElement): webdriver.promise.Promise<any> {
isElementPresent(locatorOrElement: ProtractorBy|WebElement): wdpromise.Promise<any> {
let element =
((locatorOrElement as any).isPresent) ? locatorOrElement : this.element(locatorOrElement);
return (element as any).isPresent();
Expand Down Expand Up @@ -646,7 +645,7 @@ export class ProtractorBrowser extends Webdriver {
}

/**
* @see webdriver.WebDriver.get
* @see WebDriver.get
*
* Navigate to the given destination and loads mock modules before
* Angular. Assumes that the page being loaded uses Angular.
Expand Down Expand Up @@ -778,7 +777,7 @@ export class ProtractorBrowser extends Webdriver {
}

/**
* @see webdriver.WebDriver.refresh
* @see WebDriver.refresh
*
* Makes a full reload of the current page and loads mock modules before
* Angular. Assumes that the page being loaded uses Angular.
Expand Down Expand Up @@ -820,10 +819,10 @@ export class ProtractorBrowser extends Webdriver {
* .toBe('http://angular.github.io/protractor/#/api');
*
* @param {string} url In page URL using the same syntax as $location.url()
* @returns {!webdriver.promise.Promise} A promise that will resolve once
* @returns {!wdpromise.Promise} A promise that will resolve once
* page has been changed.
*/
setLocation(url: string): webdriver.promise.Promise<any> {
setLocation(url: string): wdpromise.Promise<any> {
this.waitForAngular();
return this
.executeScriptWithDescription(
Expand All @@ -842,10 +841,10 @@ export class ProtractorBrowser extends Webdriver {
* browser.get('http://angular.github.io/protractor/#/api');
* expect(browser.getLocationAbsUrl())
* .toBe('http://angular.github.io/protractor/#/api');
* @returns {webdriver.promise.Promise<string>} The current absolute url from
* @returns {wdpromise.Promise<string>} The current absolute url from
* AngularJS.
*/
getLocationAbsUrl(): webdriver.promise.Promise<any> {
getLocationAbsUrl(): wdpromise.Promise<any> {
this.waitForAngular();
return this.executeScriptWithDescription(
clientSideScripts.getLocationAbsUrl, 'Protractor.getLocationAbsUrl()', this.rootEl);
Expand Down Expand Up @@ -930,7 +929,7 @@ export class ProtractorBrowser extends Webdriver {
* @param {number=} opt_debugPort Optional port to use for the debugging
* process
*/
pause(opt_debugPort?: number): webdriver.promise.Promise<any> {
pause(opt_debugPort?: number): wdpromise.Promise<any> {
if (this.debugHelper.isAttached()) {
logger.info('Encountered browser.pause(), but debugger already attached.');
return wdpromise.fulfilled(true);
Expand Down Expand Up @@ -959,7 +958,7 @@ export class ProtractorBrowser extends Webdriver {
/**
* Create a new instance of Browser by wrapping a webdriver instance.
*
* @param {webdriver.WebDriver} webdriver The configured webdriver instance.
* @param {WebDriver} webdriver The configured webdriver instance.
* @param {string=} baseUrl A URL to prepend to relative gets.
* @param {string=} rootElement The css selector for the element which is the
* root of the Angular app.
Expand Down
2 changes: 1 addition & 1 deletion lib/ptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Ptor {
By: ProtractorBy;
by: ProtractorBy;
wrapDriver:
(webdriver: webdriver.WebDriver, baseUrl?: string, rootElement?: string,
(webdriver: WebDriver, baseUrl?: string, rootElement?: string,
untrackOutstandingTimeouts?: boolean) => ProtractorBrowser;
ExpectedConditions: ProtractorExpectedConditions;

Expand Down