diff --git a/lib/browser.ts b/lib/browser.ts index c4c141216..7ff254eb6 100644 --- a/lib/browser.ts +++ b/lib/browser.ts @@ -589,10 +589,16 @@ export class ProtractorBrowser extends Webdriver { * @returns {!webdriver.promise.Promise} A promise that will resolve to whether * the element is present on the page. */ - isElementPresent(locatorOrElement: ProtractorBy|WebElement): wdpromise.Promise { - let element = - ((locatorOrElement as any).isPresent) ? locatorOrElement : this.element(locatorOrElement); - return (element as any).isPresent(); + isElementPresent(locatorOrElement: Locator|WebElement|ElementFinder): wdpromise.Promise { + let element: ElementFinder; + if (locatorOrElement instanceof ElementFinder) { + element = locatorOrElement; + } else if (locatorOrElement instanceof WebElement) { + element = ElementFinder.fromWebElement_(this, locatorOrElement); + } else { + element = this.element(locatorOrElement); + } + return element.isPresent(); } /** diff --git a/lib/element.ts b/lib/element.ts index 8405093af..724c7ac45 100644 --- a/lib/element.ts +++ b/lib/element.ts @@ -844,7 +844,7 @@ export class ElementFinder extends WebdriverWebElement { }); } - static fromWebElement_(browser: ProtractorBrowser, webElem: WebElement, locator: Locator): + static fromWebElement_(browser: ProtractorBrowser, webElem: WebElement, locator?: Locator): ElementFinder { let getWebElements = () => { return wdpromise.fulfilled([webElem]);