forked from SunGard-Labs/sg-protractor-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dom.ts
26 lines (20 loc) · 815 Bytes
/
dom.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { ProtractorBrowser, promise, ElementFinder } from 'protractor';
import { WebdriverWebElement } from 'protractor/built/element';
import { BaseUtil } from './base';
export class DomUtil extends BaseUtil {
constructor(browser?: ProtractorBrowser) {
super(browser);
}
public waitForNotDisplayed(element: ElementFinder, timeout = 1000): promise.Promise<boolean> {
return this.browser.wait(() => {
let d = promise.defer<boolean>();
(<WebdriverWebElement>element).isDisplayed().then((isDisplayed: boolean) => {
d.fulfill(!isDisplayed);
});
return d.promise;
}, timeout);
}
public waitForDisplayed(element: ElementFinder, timeout = 1000): promise.Promise<boolean> {
return this.browser.wait((<WebdriverWebElement>element).isDisplayed, timeout);
}
}