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

46 lines
1.1 KiB
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);
}
export function setProtractorToHybridMode() {
setProtractorToNg1Mode();
browser.ng12Hybrid = true;
// remove once waitForNg1AsyncBootstrap() is removed as well
browser.ignoreSynchronization = false;
2016-11-08 12:47:39 -05:00
}