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

Commit

Permalink
fix(isElementPresent): for un-wrapped WebElements, `browser.isEleme…
Browse files Browse the repository at this point in the history
…ntPresent` was broken (#3871)

Closes #3864
  • Loading branch information
sjelin authored and cnishina committed Dec 22, 2016
1 parent 74e3bad commit 1345137
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
let element =
((locatorOrElement as any).isPresent) ? locatorOrElement : this.element(locatorOrElement);
return (element as any).isPresent();
isElementPresent(locatorOrElement: Locator|WebElement|ElementFinder): wdpromise.Promise<any> {
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();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 1345137

Please sign in to comment.