mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
899f190da7
* test: add class with e2e test utilities * Adds a class that simplifies some common and hard to remember Protractor expressions. * Refactors the existing tests to use the new utilities. Fixes #2025. * Add types to the e2e utils and fix the selector on the dialog tests. * Remove unnecessary rounding. * Remove `any` cast. * Simplify the slide toggle tests. * Split the E2E utils class into smaller files. * Fix a leftover.
19 lines
531 B
TypeScript
19 lines
531 B
TypeScript
import {ElementFinder, by, element, ProtractorBy, browser} from 'protractor';
|
|
|
|
/**
|
|
* Normalizes either turning a selector into an
|
|
* ElementFinder or returning the finder itself.
|
|
*/
|
|
export function getElement(el: FinderResult): ElementFinder {
|
|
return typeof el === 'string' ? element(by.css(el)) : el;
|
|
}
|
|
|
|
/**
|
|
* Waits for an element to be rendered.
|
|
*/
|
|
export function waitForElement(selector: string) {
|
|
return browser.isElementPresent(by.css(selector) as ProtractorBy);
|
|
}
|
|
|
|
export type FinderResult = ElementFinder | string;
|