1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { __awaiter } from "tslib";
|
---|
9 | import { HarnessEnvironment } from '@angular/cdk/testing';
|
---|
10 | import * as webdriver from 'selenium-webdriver';
|
---|
11 | import { SeleniumWebDriverElement } from './selenium-web-driver-element';
|
---|
12 | /** The default environment options. */
|
---|
13 | const defaultEnvironmentOptions = {
|
---|
14 | queryFn: (selector, root) => __awaiter(void 0, void 0, void 0, function* () { return root().findElements(webdriver.By.css(selector)); })
|
---|
15 | };
|
---|
16 | /**
|
---|
17 | * This function is meant to be executed in the browser. It taps into the hooks exposed by Angular
|
---|
18 | * and invokes the specified `callback` when the application is stable (no more pending tasks).
|
---|
19 | */
|
---|
20 | function whenStable(callback) {
|
---|
21 | Promise.all(window.frameworkStabilizers.map(stabilizer => new Promise(stabilizer)))
|
---|
22 | .then(callback);
|
---|
23 | }
|
---|
24 | /**
|
---|
25 | * This function is meant to be executed in the browser. It checks whether the Angular framework has
|
---|
26 | * bootstrapped yet.
|
---|
27 | */
|
---|
28 | function isBootstrapped() {
|
---|
29 | return !!window.frameworkStabilizers;
|
---|
30 | }
|
---|
31 | /** Waits for angular to be ready after the page load. */
|
---|
32 | export function waitForAngularReady(wd) {
|
---|
33 | return __awaiter(this, void 0, void 0, function* () {
|
---|
34 | yield wd.wait(() => wd.executeScript(isBootstrapped));
|
---|
35 | yield wd.executeAsyncScript(whenStable);
|
---|
36 | });
|
---|
37 | }
|
---|
38 | /** A `HarnessEnvironment` implementation for WebDriver. */
|
---|
39 | export class SeleniumWebDriverHarnessEnvironment extends HarnessEnvironment {
|
---|
40 | constructor(rawRootElement, options) {
|
---|
41 | super(rawRootElement);
|
---|
42 | this._options = Object.assign(Object.assign({}, defaultEnvironmentOptions), options);
|
---|
43 | }
|
---|
44 | /** Gets the ElementFinder corresponding to the given TestElement. */
|
---|
45 | static getNativeElement(el) {
|
---|
46 | if (el instanceof SeleniumWebDriverElement) {
|
---|
47 | return el.element();
|
---|
48 | }
|
---|
49 | throw Error('This TestElement was not created by the WebDriverHarnessEnvironment');
|
---|
50 | }
|
---|
51 | /** Creates a `HarnessLoader` rooted at the document root. */
|
---|
52 | static loader(driver, options) {
|
---|
53 | return new SeleniumWebDriverHarnessEnvironment(() => driver.findElement(webdriver.By.css('body')), options);
|
---|
54 | }
|
---|
55 | /**
|
---|
56 | * Flushes change detection and async tasks captured in the Angular zone.
|
---|
57 | * In most cases it should not be necessary to call this manually. However, there may be some edge
|
---|
58 | * cases where it is needed to fully flush animation events.
|
---|
59 | */
|
---|
60 | forceStabilize() {
|
---|
61 | return __awaiter(this, void 0, void 0, function* () {
|
---|
62 | yield this.rawRootElement().getDriver().executeAsyncScript(whenStable);
|
---|
63 | });
|
---|
64 | }
|
---|
65 | /** @docs-private */
|
---|
66 | waitForTasksOutsideAngular() {
|
---|
67 | return __awaiter(this, void 0, void 0, function* () {
|
---|
68 | // TODO: figure out how we can do this for the webdriver environment.
|
---|
69 | // https://github.com/angular/components/issues/17412
|
---|
70 | });
|
---|
71 | }
|
---|
72 | /** Gets the root element for the document. */
|
---|
73 | getDocumentRoot() {
|
---|
74 | return () => this.rawRootElement().getDriver().findElement(webdriver.By.css('body'));
|
---|
75 | }
|
---|
76 | /** Creates a `TestElement` from a raw element. */
|
---|
77 | createTestElement(element) {
|
---|
78 | return new SeleniumWebDriverElement(element, () => this.forceStabilize());
|
---|
79 | }
|
---|
80 | /** Creates a `HarnessLoader` rooted at the given raw element. */
|
---|
81 | createEnvironment(element) {
|
---|
82 | return new SeleniumWebDriverHarnessEnvironment(element, this._options);
|
---|
83 | }
|
---|
84 | // Note: This seems to be working, though we may need to re-evaluate if we encounter issues with
|
---|
85 | // stale element references. `() => Promise<webdriver.WebElement[]>` seems like a more correct
|
---|
86 | // return type, though supporting it would require changes to the public harness API.
|
---|
87 | /**
|
---|
88 | * Gets a list of all elements matching the given selector under this environment's root element.
|
---|
89 | */
|
---|
90 | getAllRawElements(selector) {
|
---|
91 | return __awaiter(this, void 0, void 0, function* () {
|
---|
92 | const els = yield this._options.queryFn(selector, this.rawRootElement);
|
---|
93 | return els.map((x) => () => x);
|
---|
94 | });
|
---|
95 | }
|
---|
96 | }
|
---|
97 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VsZW5pdW0td2ViLWRyaXZlci1oYXJuZXNzLWVudmlyb25tZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2Nkay90ZXN0aW5nL3NlbGVuaXVtLXdlYmRyaXZlci9zZWxlbml1bS13ZWItZHJpdmVyLWhhcm5lc3MtZW52aXJvbm1lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOztBQUVILE9BQU8sRUFBQyxrQkFBa0IsRUFBNkIsTUFBTSxzQkFBc0IsQ0FBQztBQUNwRixPQUFPLEtBQUssU0FBUyxNQUFNLG9CQUFvQixDQUFDO0FBQ2hELE9BQU8sRUFBQyx3QkFBd0IsRUFBQyxNQUFNLCtCQUErQixDQUFDO0FBNkJ2RSx1Q0FBdUM7QUFDdkMsTUFBTSx5QkFBeUIsR0FBdUM7SUFDcEUsT0FBTyxFQUFFLENBQU8sUUFBZ0IsRUFBRSxJQUFnQyxFQUFFLEVBQUUsa0RBQ2xFLE9BQUEsSUFBSSxFQUFFLENBQUMsWUFBWSxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsR0FBRyxDQUFDLFFBQVEsQ0FBQyxDQUFDLENBQUEsR0FBQTtDQUNwRCxDQUFDO0FBRUY7OztHQUdHO0FBQ0gsU0FBUyxVQUFVLENBQUMsUUFBc0M7SUFDeEQsT0FBTyxDQUFDLEdBQUcsQ0FBQyxNQUFNL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