UNPKG

1.46 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3/*
4 * This is an mock implementation of the Driver Provider.
5 * It returns a fake webdriver and never actually contacts a selenium
6 * server.
7 */
8const q = require("q");
9const selenium_webdriver_1 = require("selenium-webdriver");
10const driverProvider_1 = require("./driverProvider");
11class MockExecutor {
12 execute(command) { }
13}
14exports.MockExecutor = MockExecutor;
15class Mock extends driverProvider_1.DriverProvider {
16 constructor(config) {
17 super(config);
18 }
19 /**
20 * An execute function that returns a promise with a test value.
21 */
22 execute() {
23 let deferred = q.defer();
24 deferred.resolve({ value: 'test_response' });
25 return deferred.promise;
26 }
27 /**
28 * Configure and launch (if applicable) the object's environment.
29 * @public
30 * @return {q.promise} A promise which will resolve immediately.
31 */
32 setupDriverEnv() {
33 return q.fcall(function () { });
34 }
35 /**
36 * Create a new driver.
37 *
38 * @public
39 * @override
40 * @return webdriver instance
41 */
42 getNewDriver() {
43 let mockSession = new selenium_webdriver_1.Session('test_session_id', {});
44 let newDriver = new selenium_webdriver_1.WebDriver(mockSession, new MockExecutor());
45 this.drivers_.push(newDriver);
46 return newDriver;
47 }
48}
49exports.Mock = Mock;
50//# sourceMappingURL=mock.js.map
\No newline at end of file