angular-cn/public/docs/_examples/protractor-helpers.ts

41 lines
1018 B
TypeScript
Raw Normal View History

2016-11-08 12:47:39 -05:00
import { browser, element, by } from 'protractor';
export var appLang = {
appIsTs: false,
appIsJs: false,
appIsDart: false,
appIsUnknown: false
};
export function describeIf(cond: boolean, name: string, func: () => void): void {
if (cond) {
describe(name, func);
} else {
xdescribe(name, func);
}
}
export function itIf(cond: boolean, name: string, func: (done: DoneFn) => void): void {
if (cond) {
it(name, func);
} else {
xit(name, func);
}
}
export function setProtractorToNg1Mode(): void {
browser.rootEl = 'body';
}
2016-11-08 12:47:39 -05:00
// Protractor doesn't support the UpgradeAdapter's asynchronous
// bootstrap with Angular 1 at the moment. Get around it by
// waiting for an element to get `ng-scope` class.
export function waitForNg1AsyncBootstrap() {
browser.ignoreSynchronization = true;
2016-11-08 12:47:39 -05:00
browser.driver.wait(function() {
return element(by.css('.ng-scope')).isPresent();
}, 5000);
2016-11-09 09:23:59 -05:00
// Use this instead when upgrading to protractor > 4.0.10
// browser.ng12Hybrid = true;
2016-11-08 12:47:39 -05:00
}