@testring/plugin-selenium-driver 0.7.5 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.d.ts +132 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +750 -887
- package/dist/plugin/index.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +6 -6
- package/src/plugin/index.ts +62 -26
- package/tsconfig.build.json +10 -0
package/dist/plugin/index.js
CHANGED
|
@@ -1,34 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
10
24
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
21
27
|
};
|
|
22
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
29
|
exports.SeleniumPlugin = void 0;
|
|
24
30
|
exports.default = seleniumProxy;
|
|
25
31
|
const webdriverio_1 = require("webdriverio");
|
|
26
|
-
const deepmerge = require("deepmerge");
|
|
32
|
+
const deepmerge = __importStar(require("deepmerge"));
|
|
27
33
|
const child_process_1 = require("@testring/child-process");
|
|
28
34
|
const logger_1 = require("@testring/logger");
|
|
29
35
|
const dwnld_collector_crx_1 = require("@testring/dwnld-collector-crx");
|
|
30
36
|
const code_coverage_client_1 = require("@nullcc/code-coverage-client");
|
|
31
|
-
const webdriver_1 = require("webdriver");
|
|
37
|
+
const webdriver_1 = __importDefault(require("webdriver"));
|
|
32
38
|
const DEFAULT_CONFIG = {
|
|
33
39
|
recorderExtension: false,
|
|
34
40
|
clientCheckInterval: 5 * 1000,
|
|
@@ -38,7 +44,6 @@ const DEFAULT_CONFIG = {
|
|
|
38
44
|
capabilities: {
|
|
39
45
|
browserName: 'chrome',
|
|
40
46
|
'goog:chromeOptions': {
|
|
41
|
-
// for local ChromeDriver
|
|
42
47
|
args: [],
|
|
43
48
|
},
|
|
44
49
|
'wdio:enforceWebDriverClassic': true,
|
|
@@ -55,8 +60,9 @@ function stringifyWindowFeatures(windowFeatures) {
|
|
|
55
60
|
result = windowFeatures;
|
|
56
61
|
}
|
|
57
62
|
else {
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
const features = windowFeatures;
|
|
64
|
+
result = Object.keys(features)
|
|
65
|
+
.map((key) => `${key}=${features[key]}`)
|
|
60
66
|
.join(',');
|
|
61
67
|
}
|
|
62
68
|
return result;
|
|
@@ -66,6 +72,7 @@ class SeleniumPlugin {
|
|
|
66
72
|
this.logger = logger_1.loggerClient.withPrefix('[selenium-browser-process]');
|
|
67
73
|
this.expiredBrowserClients = new Set();
|
|
68
74
|
this.browserClients = new Map();
|
|
75
|
+
this.customBrowserClientsConfigs = new Map();
|
|
69
76
|
this.waitForReadyState = Promise.resolve();
|
|
70
77
|
this.incrementWinId = 0;
|
|
71
78
|
this.config = this.createConfig(config);
|
|
@@ -76,15 +83,16 @@ class SeleniumPlugin {
|
|
|
76
83
|
}
|
|
77
84
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
78
85
|
createConfig(config) {
|
|
79
|
-
var _a
|
|
86
|
+
var _a;
|
|
80
87
|
const mergedConfig = deepmerge.all([DEFAULT_CONFIG, config], {
|
|
81
88
|
clone: true,
|
|
82
89
|
});
|
|
83
90
|
if (!mergedConfig.hostname && mergedConfig.host) {
|
|
84
91
|
mergedConfig.hostname = mergedConfig.host;
|
|
85
92
|
}
|
|
86
|
-
const
|
|
87
|
-
|
|
93
|
+
const capabilities = mergedConfig.capabilities;
|
|
94
|
+
const googleChromeOptions = capabilities === null || capabilities === void 0 ? void 0 : capabilities['goog:chromeOptions'];
|
|
95
|
+
if ((_a = googleChromeOptions === null || googleChromeOptions === void 0 ? void 0 : googleChromeOptions.args) === null || _a === void 0 ? void 0 : _a.includes('--headless=new')) {
|
|
88
96
|
const extensions = googleChromeOptions.extensions;
|
|
89
97
|
const dowldMonitorCrx = (0, dwnld_collector_crx_1.getCrxBase64)();
|
|
90
98
|
if (extensions) {
|
|
@@ -129,44 +137,41 @@ class SeleniumPlugin {
|
|
|
129
137
|
}
|
|
130
138
|
return [`-Dwebdriver.chrome.driver=${chromeDriverPath}`];
|
|
131
139
|
}
|
|
132
|
-
runLocalSelenium() {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
this.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
});
|
|
140
|
+
async runLocalSelenium() {
|
|
141
|
+
const seleniumServer = require('selenium-server');
|
|
142
|
+
const seleniumJarPath = seleniumServer.path;
|
|
143
|
+
this.logger.debug('Init local selenium server');
|
|
144
|
+
try {
|
|
145
|
+
this.localSelenium = (0, child_process_1.spawnWithPipes)('java', [
|
|
146
|
+
...this.getChromeDriverArgs(),
|
|
147
|
+
'-jar',
|
|
148
|
+
seleniumJarPath,
|
|
149
|
+
'-port',
|
|
150
|
+
this.config.port,
|
|
151
|
+
]);
|
|
152
|
+
this.waitForReadyState = new Promise((resolve, reject) => {
|
|
153
|
+
var _a;
|
|
154
|
+
if ((_a = this.localSelenium) === null || _a === void 0 ? void 0 : _a.stderr) {
|
|
155
|
+
this.localSelenium.stderr.on('data', (data) => {
|
|
156
|
+
const message = data.toString();
|
|
157
|
+
this.logger.verbose(message);
|
|
158
|
+
if (message.includes('SeleniumServer.boot')) {
|
|
159
|
+
delay(500).then(resolve);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
reject(new Error('There is no STDERR on selenium worker'));
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
this.logger.error('Local selenium server init failed', err);
|
|
170
|
+
}
|
|
164
171
|
}
|
|
165
172
|
getApplicantSessionId(applicant) {
|
|
166
173
|
const item = this.browserClients.get(applicant);
|
|
167
|
-
|
|
168
|
-
return item.sessionId;
|
|
169
|
-
}
|
|
174
|
+
return item === null || item === void 0 ? void 0 : item.sessionId;
|
|
170
175
|
}
|
|
171
176
|
hasBrowserClient(applicant) {
|
|
172
177
|
return this.browserClients.has(applicant);
|
|
@@ -178,878 +183,736 @@ class SeleniumPlugin {
|
|
|
178
183
|
}
|
|
179
184
|
throw new Error('Browser client is not found');
|
|
180
185
|
}
|
|
181
|
-
pingClients() {
|
|
182
|
-
|
|
183
|
-
|
|
186
|
+
async pingClients() {
|
|
187
|
+
for (const [applicant] of this.browserClients) {
|
|
188
|
+
try {
|
|
189
|
+
await this.execute(applicant, '(function () {})()', []);
|
|
190
|
+
}
|
|
191
|
+
catch (e) {
|
|
192
|
+
/* ignore */
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async closeExpiredClients() {
|
|
197
|
+
const timeLimit = Date.now() - this.config.clientTimeout;
|
|
198
|
+
for (const [applicant, clientData] of this.browserClients) {
|
|
199
|
+
if (clientData.initTime < timeLimit) {
|
|
200
|
+
this.logger.warn(`Session applicant ${applicant} marked as expired`);
|
|
184
201
|
try {
|
|
185
|
-
|
|
202
|
+
await this.end(applicant);
|
|
186
203
|
}
|
|
187
204
|
catch (e) {
|
|
188
|
-
|
|
205
|
+
this.logger.error(`Session applicant ${applicant} failed to stop`, e);
|
|
189
206
|
}
|
|
207
|
+
this.expiredBrowserClients.add(applicant);
|
|
190
208
|
}
|
|
191
|
-
}
|
|
209
|
+
}
|
|
192
210
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
yield this.end(applicant);
|
|
201
|
-
}
|
|
202
|
-
catch (e) {
|
|
203
|
-
this.logger.error(`Session applicant ${applicant} failed to stop`, e);
|
|
204
|
-
}
|
|
205
|
-
this.expiredBrowserClients.add(applicant);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
});
|
|
211
|
+
async checkClientsTimeout() {
|
|
212
|
+
if (this.config.clientTimeout === 0) {
|
|
213
|
+
await this.pingClients();
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
await this.closeExpiredClients();
|
|
217
|
+
}
|
|
209
218
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (this.config.clientTimeout === 0) {
|
|
213
|
-
yield this.pingClients();
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
yield this.closeExpiredClients();
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
+
setCustomBrowserClientConfig(applicant, config) {
|
|
220
|
+
this.customBrowserClientsConfigs.set(applicant, config);
|
|
219
221
|
}
|
|
220
|
-
|
|
221
|
-
return
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
if (this.expiredBrowserClients.has(applicant)) {
|
|
229
|
-
throw Error(`This session expired in ${this.config.clientTimeout}ms`);
|
|
230
|
-
}
|
|
231
|
-
const _config = deepmerge.all([
|
|
232
|
-
{},
|
|
233
|
-
this.config,
|
|
234
|
-
config || {},
|
|
235
|
-
]);
|
|
236
|
-
const client = yield (0, webdriverio_1.remote)(_config);
|
|
237
|
-
let sessionId;
|
|
238
|
-
if (client.sessionId) {
|
|
239
|
-
sessionId = client.sessionId;
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
throw Error('Session can not be null');
|
|
243
|
-
}
|
|
244
|
-
const customClient = this.addCustromMethods(client);
|
|
245
|
-
let cdpCoverageCollector;
|
|
246
|
-
if (this.config.cdpCoverage) {
|
|
247
|
-
this.logger.debug('Started to init cdp coverage....');
|
|
248
|
-
cdpCoverageCollector = yield this.enableCDPCoverageClient(client);
|
|
249
|
-
this.logger.debug('ended to init cdp coverage....');
|
|
250
|
-
}
|
|
222
|
+
getCustomBrowserClientConfig(applicant) {
|
|
223
|
+
return this.customBrowserClientsConfigs.get(applicant);
|
|
224
|
+
}
|
|
225
|
+
async createClient(applicant, config) {
|
|
226
|
+
await this.waitForReadyState;
|
|
227
|
+
const clientData = this.browserClients.get(applicant);
|
|
228
|
+
if (clientData) {
|
|
251
229
|
this.browserClients.set(applicant, {
|
|
252
|
-
|
|
253
|
-
sessionId,
|
|
230
|
+
...clientData,
|
|
254
231
|
initTime: Date.now(),
|
|
255
|
-
cdpCoverageCollector: cdpCoverageCollector
|
|
256
|
-
? cdpCoverageCollector
|
|
257
|
-
: null,
|
|
258
232
|
});
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (this.expiredBrowserClients.has(applicant)) {
|
|
236
|
+
throw Error(`This session expired in ${this.config.clientTimeout}ms`);
|
|
237
|
+
}
|
|
238
|
+
const _config = deepmerge.all([
|
|
239
|
+
{},
|
|
240
|
+
this.config,
|
|
241
|
+
config || {},
|
|
242
|
+
this.customBrowserClientsConfigs.get(applicant) || {},
|
|
243
|
+
]);
|
|
244
|
+
const client = await (0, webdriverio_1.remote)(_config);
|
|
245
|
+
let sessionId;
|
|
246
|
+
if (client.sessionId) {
|
|
247
|
+
sessionId = client.sessionId;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
throw Error('Session can not be null');
|
|
251
|
+
}
|
|
252
|
+
const customClient = this.addCustromMethods(client);
|
|
253
|
+
let cdpCoverageCollector;
|
|
254
|
+
if (this.config.cdpCoverage) {
|
|
255
|
+
this.logger.debug('Started to init cdp coverage....');
|
|
256
|
+
cdpCoverageCollector = await this.enableCDPCoverageClient(client);
|
|
257
|
+
this.logger.debug('ended to init cdp coverage....');
|
|
258
|
+
}
|
|
259
|
+
this.browserClients.set(applicant, {
|
|
260
|
+
client: customClient,
|
|
261
|
+
sessionId,
|
|
262
|
+
initTime: Date.now(),
|
|
263
|
+
cdpCoverageCollector: cdpCoverageCollector
|
|
264
|
+
? cdpCoverageCollector
|
|
265
|
+
: null,
|
|
278
266
|
});
|
|
267
|
+
this.logger.debug(`Started session for applicant: ${applicant}. Session id: ${sessionId}`);
|
|
279
268
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
269
|
+
async enableCDPCoverageClient(client) {
|
|
270
|
+
if (this.config.host === undefined) {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
//accurate
|
|
274
|
+
if (!client.capabilities['se:cdp']) {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
const cdpAddress = client.capabilities['se:cdp'];
|
|
278
|
+
const collector = new code_coverage_client_1.CDPCoverageCollector({
|
|
279
|
+
wsEndpoint: cdpAddress,
|
|
280
|
+
});
|
|
281
|
+
await collector.init();
|
|
282
|
+
await collector.start();
|
|
283
|
+
return collector;
|
|
284
|
+
}
|
|
285
|
+
async getCdpCoverageFile(applicant) {
|
|
286
|
+
const clientData = this.browserClients.get(applicant);
|
|
287
|
+
this.logger.debug(`start upload coverage for applicant ${applicant}`);
|
|
288
|
+
if (!clientData) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const coverageCollector = clientData.cdpCoverageCollector;
|
|
292
|
+
if (!coverageCollector) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const { coverage } = await coverageCollector.collect();
|
|
296
|
+
await coverageCollector.stop();
|
|
297
|
+
return [Buffer.from(JSON.stringify(coverage))];
|
|
295
298
|
}
|
|
296
299
|
addCustromMethods(client) {
|
|
297
300
|
return client;
|
|
298
301
|
}
|
|
299
|
-
end(applicant) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
yield attachedClient.deleteSession();
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
catch (err) {
|
|
331
|
-
this.logger.error(`Old session ${startingSessionID} delete error`, err);
|
|
332
|
-
}
|
|
333
|
-
try {
|
|
334
|
-
yield client.deleteSession();
|
|
335
|
-
}
|
|
336
|
-
catch (err) {
|
|
337
|
-
this.logger.error(`New session ${client.sessionId} delete error`, err);
|
|
302
|
+
async end(applicant) {
|
|
303
|
+
await this.waitForReadyState;
|
|
304
|
+
if (!this.hasBrowserClient(applicant)) {
|
|
305
|
+
this.logger.warn(`No ${applicant} is registered`);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const client = this.getBrowserClient(applicant);
|
|
309
|
+
try {
|
|
310
|
+
await this.alertDismiss(applicant);
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
/* ignore */
|
|
314
|
+
}
|
|
315
|
+
const startingSessionID = this.getApplicantSessionId(applicant);
|
|
316
|
+
const sessionID = client.sessionId;
|
|
317
|
+
if (startingSessionID === sessionID) {
|
|
318
|
+
this.logger.debug(`Stopping sessions for applicant ${applicant}. Session id: ${sessionID}`);
|
|
319
|
+
await client.deleteSession();
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
await this.logger.stepWarning(`Stopping sessions for applicant warning ${applicant}. ` +
|
|
323
|
+
`Session ids are not equal, started with - ${startingSessionID}, ended with - ${sessionID}`, async () => {
|
|
324
|
+
try {
|
|
325
|
+
if (startingSessionID) {
|
|
326
|
+
const attachedClient = webdriver_1.default.attachToSession({
|
|
327
|
+
sessionId: startingSessionID,
|
|
328
|
+
});
|
|
329
|
+
await attachedClient.deleteSession();
|
|
338
330
|
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
yield delay(this.config.delayAfterSessionClose);
|
|
344
|
-
}
|
|
345
|
-
this.browserClients.delete(applicant);
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
kill() {
|
|
349
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
350
|
-
var _a, _b, _c, _d;
|
|
351
|
-
this.logger.debug('Kill command is called');
|
|
352
|
-
// Close all browser sessions
|
|
353
|
-
for (const applicant of this.browserClients.keys()) {
|
|
331
|
+
}
|
|
332
|
+
catch (err) {
|
|
333
|
+
this.logger.error(`Old session ${startingSessionID} delete error`, err);
|
|
334
|
+
}
|
|
354
335
|
try {
|
|
355
|
-
|
|
336
|
+
await client.deleteSession();
|
|
356
337
|
}
|
|
357
|
-
catch (
|
|
358
|
-
this.logger.error(
|
|
338
|
+
catch (err) {
|
|
339
|
+
this.logger.error(`New session ${client.sessionId} delete error`, err);
|
|
359
340
|
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
// Empirically: pause after close() to let Selenium kill ChromeDriver cleanly (no zombie process).
|
|
344
|
+
if (this.config.delayAfterSessionClose) {
|
|
345
|
+
await delay(this.config.delayAfterSessionClose);
|
|
346
|
+
}
|
|
347
|
+
this.browserClients.delete(applicant);
|
|
348
|
+
this.customBrowserClientsConfigs.delete(applicant);
|
|
349
|
+
}
|
|
350
|
+
async kill() {
|
|
351
|
+
var _a, _b, _c, _d;
|
|
352
|
+
this.logger.debug('Kill command is called');
|
|
353
|
+
// Close all browser sessions
|
|
354
|
+
for (const applicant of this.browserClients.keys()) {
|
|
355
|
+
try {
|
|
356
|
+
await this.end(applicant);
|
|
360
357
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
yield this.stopAllSessions();
|
|
358
|
+
catch (e) {
|
|
359
|
+
this.logger.error(e);
|
|
364
360
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
(
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
this.logger.warn(`Selenium did not exit in time. Sending SIGKILL.`);
|
|
390
|
-
this.localSelenium.kill('SIGKILL');
|
|
391
|
-
}
|
|
392
|
-
resolve();
|
|
393
|
-
}, 3000);
|
|
361
|
+
}
|
|
362
|
+
// If using 'local' mode, stop all active sessions
|
|
363
|
+
if (this.config.workerLimit === 'local') {
|
|
364
|
+
await this.stopAllSessions();
|
|
365
|
+
}
|
|
366
|
+
if (this.localSelenium) {
|
|
367
|
+
// remove listener
|
|
368
|
+
if (this.localSelenium.stderr) {
|
|
369
|
+
this.localSelenium.stderr.removeAllListeners('data');
|
|
370
|
+
(_a = this.localSelenium.stdout) === null || _a === void 0 ? void 0 : _a.removeAllListeners();
|
|
371
|
+
}
|
|
372
|
+
// Ensure all pipes are closed
|
|
373
|
+
(_b = this.localSelenium.stdout) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
374
|
+
(_c = this.localSelenium.stderr) === null || _c === void 0 ? void 0 : _c.destroy();
|
|
375
|
+
(_d = this.localSelenium.stdin) === null || _d === void 0 ? void 0 : _d.destroy();
|
|
376
|
+
this.logger.debug(`Stopping local Selenium server (PID: ${this.localSelenium.pid})`);
|
|
377
|
+
// Try SIGTERM first
|
|
378
|
+
this.localSelenium.kill('SIGTERM');
|
|
379
|
+
// Wait for exit event with a timeout (ensures it does not hang forever)
|
|
380
|
+
const waitForExit = new Promise((resolve) => {
|
|
381
|
+
var _a;
|
|
382
|
+
(_a = this.localSelenium) === null || _a === void 0 ? void 0 : _a.once('exit', () => {
|
|
383
|
+
this.logger.debug('Selenium process exited.');
|
|
384
|
+
resolve();
|
|
394
385
|
});
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
yield this.createClient(applicant);
|
|
412
|
-
const client = this.getBrowserClient(applicant);
|
|
413
|
-
const element = yield client.$(selector);
|
|
414
|
-
return options && Object.keys(options).length > 0
|
|
415
|
-
? element.click(options)
|
|
416
|
-
: element.click();
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
getSize(applicant, selector) {
|
|
420
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
421
|
-
yield this.createClient(applicant);
|
|
422
|
-
const client = this.getBrowserClient(applicant);
|
|
423
|
-
const element = yield client.$(selector);
|
|
424
|
-
return element.getSize();
|
|
425
|
-
});
|
|
386
|
+
});
|
|
387
|
+
// Force kill if not exiting within 3 seconds
|
|
388
|
+
const forceKill = new Promise((resolve) => {
|
|
389
|
+
setTimeout(() => {
|
|
390
|
+
if (this.localSelenium && !this.localSelenium.killed) {
|
|
391
|
+
this.logger.warn(`Selenium did not exit in time. Sending SIGKILL.`);
|
|
392
|
+
this.localSelenium.kill('SIGKILL');
|
|
393
|
+
}
|
|
394
|
+
resolve();
|
|
395
|
+
}, 3000);
|
|
396
|
+
});
|
|
397
|
+
// Wait for either normal exit or force kill
|
|
398
|
+
await Promise.race([waitForExit, forceKill]);
|
|
399
|
+
this.localSelenium.removeAllListeners();
|
|
400
|
+
this.logger.debug('Selenium process and all associated pipes closed.');
|
|
401
|
+
}
|
|
426
402
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
403
|
+
async refresh(applicant) {
|
|
404
|
+
await this.createClient(applicant);
|
|
405
|
+
const client = this.getBrowserClient(applicant);
|
|
406
|
+
return client.refresh();
|
|
407
|
+
}
|
|
408
|
+
async click(applicant, selector, options) {
|
|
409
|
+
await this.createClient(applicant);
|
|
410
|
+
const client = this.getBrowserClient(applicant);
|
|
411
|
+
const element = await client.$(selector);
|
|
412
|
+
return options && Object.keys(options).length > 0
|
|
413
|
+
? element.click(options)
|
|
414
|
+
: element.click();
|
|
415
|
+
}
|
|
416
|
+
async getSize(applicant, selector) {
|
|
417
|
+
await this.createClient(applicant);
|
|
418
|
+
const client = this.getBrowserClient(applicant);
|
|
419
|
+
const element = await client.$(selector);
|
|
420
|
+
return element.getSize();
|
|
421
|
+
}
|
|
422
|
+
async url(applicant, val) {
|
|
423
|
+
await this.createClient(applicant);
|
|
424
|
+
const client = this.getBrowserClient(applicant);
|
|
425
|
+
if (!val) {
|
|
426
|
+
return client.getUrl();
|
|
427
|
+
}
|
|
428
|
+
return client.url(val);
|
|
436
429
|
}
|
|
437
430
|
generateWinId() {
|
|
438
431
|
this.incrementWinId++;
|
|
439
432
|
return `window-${this.incrementWinId}`;
|
|
440
433
|
}
|
|
441
|
-
newWindow(
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
return
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
return
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
return
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
windowHandleMaximize(applicant) {
|
|
602
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
603
|
-
yield this.createClient(applicant);
|
|
604
|
-
const client = this.getBrowserClient(applicant);
|
|
605
|
-
return client.maximizeWindow();
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
isEnabled(applicant, xpath) {
|
|
609
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
610
|
-
yield this.createClient(applicant);
|
|
611
|
-
const client = this.getBrowserClient(applicant);
|
|
612
|
-
const selector = yield client.$(xpath);
|
|
613
|
-
return selector.isEnabled();
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
scroll(applicant, xpath, xOffset, yOffset) {
|
|
617
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
618
|
-
yield this.createClient(applicant);
|
|
619
|
-
const client = this.getBrowserClient(applicant);
|
|
620
|
-
const element = yield client.$(xpath);
|
|
621
|
-
yield element.scrollIntoView();
|
|
622
|
-
return element.moveTo({ xOffset, yOffset });
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
scrollIntoView(applicant, xpath, scrollIntoViewOptions) {
|
|
626
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
627
|
-
yield this.createClient(applicant);
|
|
628
|
-
const client = this.getBrowserClient(applicant);
|
|
629
|
-
const element = yield client.$(xpath);
|
|
630
|
-
yield element.scrollIntoView(scrollIntoViewOptions !== null ? scrollIntoViewOptions : undefined);
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
isAlertOpen(applicant) {
|
|
634
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
635
|
-
yield this.createClient(applicant);
|
|
636
|
-
const client = this.getBrowserClient(applicant);
|
|
637
|
-
return client.isAlertOpen();
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
alertAccept(applicant) {
|
|
641
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
642
|
-
yield this.createClient(applicant);
|
|
643
|
-
const client = this.getBrowserClient(applicant);
|
|
644
|
-
if (yield this.isAlertOpen(applicant)) {
|
|
645
|
-
return client.acceptAlert();
|
|
646
|
-
}
|
|
647
|
-
throw Error('There is no open alert');
|
|
648
|
-
});
|
|
434
|
+
async newWindow(applicant, val, windowName, windowFeatures = {}) {
|
|
435
|
+
await this.createClient(applicant);
|
|
436
|
+
const client = this.getBrowserClient(applicant);
|
|
437
|
+
const args = stringifyWindowFeatures(windowFeatures);
|
|
438
|
+
const newWindow = await client.newWindow(val, {
|
|
439
|
+
windowName: windowName || this.generateWinId(),
|
|
440
|
+
windowFeatures: args,
|
|
441
|
+
});
|
|
442
|
+
return (newWindow === null || newWindow === void 0 ? void 0 : newWindow.handle) || newWindow;
|
|
443
|
+
}
|
|
444
|
+
async waitForExist(applicant, xpath, timeout) {
|
|
445
|
+
await this.createClient(applicant);
|
|
446
|
+
const client = this.getBrowserClient(applicant);
|
|
447
|
+
const selector = await client.$(xpath);
|
|
448
|
+
return selector.waitForExist({ timeout });
|
|
449
|
+
}
|
|
450
|
+
async waitForVisible(applicant, xpath, timeout) {
|
|
451
|
+
await this.createClient(applicant);
|
|
452
|
+
const client = this.getBrowserClient(applicant);
|
|
453
|
+
const selector = await client.$(xpath);
|
|
454
|
+
return selector.waitForDisplayed({ timeout });
|
|
455
|
+
}
|
|
456
|
+
async isVisible(applicant, xpath) {
|
|
457
|
+
await this.createClient(applicant);
|
|
458
|
+
const client = this.getBrowserClient(applicant);
|
|
459
|
+
const selector = await client.$(xpath);
|
|
460
|
+
return selector.isDisplayed();
|
|
461
|
+
}
|
|
462
|
+
async moveToObject(applicant, xpath, xOffset = 0, yOffset = 0) {
|
|
463
|
+
await this.createClient(applicant);
|
|
464
|
+
const client = this.getBrowserClient(applicant);
|
|
465
|
+
const selector = await client.$(xpath);
|
|
466
|
+
return selector.moveTo({ xOffset, yOffset });
|
|
467
|
+
}
|
|
468
|
+
async execute(applicant, fn, args) {
|
|
469
|
+
await this.createClient(applicant);
|
|
470
|
+
const client = this.getBrowserClient(applicant);
|
|
471
|
+
return client.execute(fn, ...args);
|
|
472
|
+
}
|
|
473
|
+
async executeAsync(applicant, fn, args) {
|
|
474
|
+
await this.createClient(applicant);
|
|
475
|
+
const client = this.getBrowserClient(applicant);
|
|
476
|
+
return client.executeAsync(fn, ...args);
|
|
477
|
+
}
|
|
478
|
+
async getTitle(applicant) {
|
|
479
|
+
await this.createClient(applicant);
|
|
480
|
+
const client = this.getBrowserClient(applicant);
|
|
481
|
+
return client.getTitle();
|
|
482
|
+
}
|
|
483
|
+
async clearValue(applicant, xpath) {
|
|
484
|
+
await this.createClient(applicant);
|
|
485
|
+
const client = this.getBrowserClient(applicant);
|
|
486
|
+
const selector = await client.$(xpath);
|
|
487
|
+
return selector.clearValue();
|
|
488
|
+
}
|
|
489
|
+
async keys(applicant, value) {
|
|
490
|
+
await this.createClient(applicant);
|
|
491
|
+
const client = this.getBrowserClient(applicant);
|
|
492
|
+
return client.keys(value);
|
|
493
|
+
}
|
|
494
|
+
async elementIdText(applicant, elementId) {
|
|
495
|
+
await this.createClient(applicant);
|
|
496
|
+
const client = this.getBrowserClient(applicant);
|
|
497
|
+
return client.getElementText(elementId);
|
|
498
|
+
}
|
|
499
|
+
async elements(applicant, xpath) {
|
|
500
|
+
await this.createClient(applicant);
|
|
501
|
+
const client = this.getBrowserClient(applicant);
|
|
502
|
+
const elements = (await client.findElements('xpath', xpath));
|
|
503
|
+
return elements.map((o) => {
|
|
504
|
+
const keys = Object.keys(o);
|
|
505
|
+
const firstKey = keys[0];
|
|
506
|
+
if (firstKey === undefined) {
|
|
507
|
+
return { ELEMENT: '' };
|
|
508
|
+
}
|
|
509
|
+
return { ELEMENT: o[firstKey] };
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
async frame(applicant, frameID) {
|
|
513
|
+
await this.createClient(applicant);
|
|
514
|
+
const client = this.getBrowserClient(applicant);
|
|
515
|
+
return client.switchFrame(frameID);
|
|
516
|
+
}
|
|
517
|
+
async frameParent(applicant) {
|
|
518
|
+
await this.createClient(applicant);
|
|
519
|
+
const client = this.getBrowserClient(applicant);
|
|
520
|
+
return client.switchToParentFrame();
|
|
521
|
+
}
|
|
522
|
+
async getValue(applicant, xpath) {
|
|
523
|
+
await this.createClient(applicant);
|
|
524
|
+
const client = this.getBrowserClient(applicant);
|
|
525
|
+
const selector = await client.$(xpath);
|
|
526
|
+
return selector.getValue();
|
|
527
|
+
}
|
|
528
|
+
async setValue(applicant, xpath, value) {
|
|
529
|
+
await this.createClient(applicant);
|
|
530
|
+
const client = this.getBrowserClient(applicant);
|
|
531
|
+
const selector = await client.$(xpath);
|
|
532
|
+
return selector.setValue(value);
|
|
533
|
+
}
|
|
534
|
+
async selectByIndex(applicant, xpath, value) {
|
|
535
|
+
await this.createClient(applicant);
|
|
536
|
+
const client = this.getBrowserClient(applicant);
|
|
537
|
+
const selector = await client.$(xpath);
|
|
538
|
+
return selector.selectByIndex(value);
|
|
539
|
+
}
|
|
540
|
+
async selectByValue(applicant, xpath, value) {
|
|
541
|
+
await this.createClient(applicant);
|
|
542
|
+
const client = this.getBrowserClient(applicant);
|
|
543
|
+
const selector = await client.$(xpath);
|
|
544
|
+
return selector.selectByAttribute('value', value);
|
|
545
|
+
}
|
|
546
|
+
async selectByVisibleText(applicant, xpath, str) {
|
|
547
|
+
await this.createClient(applicant);
|
|
548
|
+
const client = this.getBrowserClient(applicant);
|
|
549
|
+
const selector = await client.$(xpath);
|
|
550
|
+
return selector.selectByVisibleText(str);
|
|
551
|
+
}
|
|
552
|
+
async getAttribute(applicant, xpath, attr) {
|
|
553
|
+
await this.createClient(applicant);
|
|
554
|
+
const client = this.getBrowserClient(applicant);
|
|
555
|
+
const selector = await client.$(xpath);
|
|
556
|
+
return selector.getAttribute(attr);
|
|
557
|
+
}
|
|
558
|
+
async windowHandleMaximize(applicant) {
|
|
559
|
+
await this.createClient(applicant);
|
|
560
|
+
const client = this.getBrowserClient(applicant);
|
|
561
|
+
return client.maximizeWindow();
|
|
562
|
+
}
|
|
563
|
+
async isEnabled(applicant, xpath) {
|
|
564
|
+
await this.createClient(applicant);
|
|
565
|
+
const client = this.getBrowserClient(applicant);
|
|
566
|
+
const selector = await client.$(xpath);
|
|
567
|
+
return selector.isEnabled();
|
|
568
|
+
}
|
|
569
|
+
async scroll(applicant, xpath, xOffset, yOffset) {
|
|
570
|
+
await this.createClient(applicant);
|
|
571
|
+
const client = this.getBrowserClient(applicant);
|
|
572
|
+
const element = await client.$(xpath);
|
|
573
|
+
await element.scrollIntoView();
|
|
574
|
+
return element.moveTo({ xOffset, yOffset });
|
|
575
|
+
}
|
|
576
|
+
async scrollIntoView(applicant, xpath, scrollIntoViewOptions) {
|
|
577
|
+
await this.createClient(applicant);
|
|
578
|
+
const client = this.getBrowserClient(applicant);
|
|
579
|
+
const element = await client.$(xpath);
|
|
580
|
+
await element.scrollIntoView(scrollIntoViewOptions !== null ? scrollIntoViewOptions : undefined);
|
|
581
|
+
}
|
|
582
|
+
async isAlertOpen(applicant) {
|
|
583
|
+
await this.createClient(applicant);
|
|
584
|
+
const client = this.getBrowserClient(applicant);
|
|
585
|
+
return client.isAlertOpen();
|
|
586
|
+
}
|
|
587
|
+
async alertAccept(applicant) {
|
|
588
|
+
await this.createClient(applicant);
|
|
589
|
+
const client = this.getBrowserClient(applicant);
|
|
590
|
+
if (await this.isAlertOpen(applicant)) {
|
|
591
|
+
return client.acceptAlert();
|
|
592
|
+
}
|
|
593
|
+
throw Error('There is no open alert');
|
|
649
594
|
}
|
|
650
|
-
alertDismiss(applicant) {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
throw Error('There is no open alert');
|
|
658
|
-
});
|
|
595
|
+
async alertDismiss(applicant) {
|
|
596
|
+
await this.createClient(applicant);
|
|
597
|
+
const client = this.getBrowserClient(applicant);
|
|
598
|
+
if (await this.isAlertOpen(applicant)) {
|
|
599
|
+
return client.dismissAlert();
|
|
600
|
+
}
|
|
601
|
+
throw Error('There is no open alert');
|
|
659
602
|
}
|
|
660
|
-
alertText(applicant) {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
603
|
+
async alertText(applicant) {
|
|
604
|
+
await this.createClient(applicant);
|
|
605
|
+
const client = this.getBrowserClient(applicant);
|
|
606
|
+
if (await this.isAlertOpen(applicant)) {
|
|
607
|
+
return client.getAlertText();
|
|
608
|
+
}
|
|
609
|
+
throw Error('There is no open alert');
|
|
610
|
+
}
|
|
611
|
+
async dragAndDrop(applicant, xpathSource, xpathDestination) {
|
|
612
|
+
await this.createClient(applicant);
|
|
613
|
+
const client = this.getBrowserClient(applicant);
|
|
614
|
+
const sourceElement = await client.$(xpathSource);
|
|
615
|
+
const destinationElement = await client.$(xpathDestination);
|
|
616
|
+
return sourceElement.dragAndDrop(destinationElement);
|
|
617
|
+
}
|
|
618
|
+
async setCookie(applicant, cookieObj) {
|
|
619
|
+
await this.createClient(applicant);
|
|
620
|
+
const client = this.getBrowserClient(applicant);
|
|
621
|
+
return await client.setCookies(cookieObj);
|
|
622
|
+
}
|
|
623
|
+
async getCookie(applicant, cookieName) {
|
|
624
|
+
var _a;
|
|
625
|
+
await this.createClient(applicant);
|
|
626
|
+
const client = this.getBrowserClient(applicant);
|
|
627
|
+
if (cookieName) {
|
|
628
|
+
try {
|
|
629
|
+
const cookies = await client.getCookies([cookieName]);
|
|
630
|
+
return (_a = cookies[0]) === null || _a === void 0 ? void 0 : _a.value;
|
|
666
631
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
}
|
|
670
|
-
dragAndDrop(applicant, xpathSource, xpathDestination) {
|
|
671
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
672
|
-
yield this.createClient(applicant);
|
|
673
|
-
const client = this.getBrowserClient(applicant);
|
|
674
|
-
const sourceElement = yield client.$(xpathSource);
|
|
675
|
-
const destinationElement = yield client.$(xpathDestination);
|
|
676
|
-
return sourceElement.dragAndDrop(destinationElement);
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
setCookie(applicant, cookieObj) {
|
|
680
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
681
|
-
yield this.createClient(applicant);
|
|
682
|
-
const client = this.getBrowserClient(applicant);
|
|
683
|
-
return yield client.setCookies(cookieObj);
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
getCookie(applicant, cookieName) {
|
|
687
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
688
|
-
var _a;
|
|
689
|
-
yield this.createClient(applicant);
|
|
690
|
-
const client = this.getBrowserClient(applicant);
|
|
691
|
-
if (cookieName) {
|
|
692
|
-
try {
|
|
693
|
-
const cookies = yield client.getCookies([cookieName]);
|
|
694
|
-
return (_a = cookies[0]) === null || _a === void 0 ? void 0 : _a.value;
|
|
695
|
-
}
|
|
696
|
-
catch (e) {
|
|
697
|
-
return undefined;
|
|
698
|
-
}
|
|
632
|
+
catch (e) {
|
|
633
|
+
return undefined;
|
|
699
634
|
}
|
|
700
|
-
|
|
701
|
-
|
|
635
|
+
}
|
|
636
|
+
return client.getAllCookies();
|
|
702
637
|
}
|
|
703
|
-
deleteCookie(applicant, cookieName) {
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
return client.deleteAllCookies();
|
|
711
|
-
});
|
|
638
|
+
async deleteCookie(applicant, cookieName) {
|
|
639
|
+
await this.createClient(applicant);
|
|
640
|
+
const client = this.getBrowserClient(applicant);
|
|
641
|
+
if (cookieName) {
|
|
642
|
+
return client.deleteCookie(cookieName);
|
|
643
|
+
}
|
|
644
|
+
return client.deleteAllCookies();
|
|
712
645
|
}
|
|
713
|
-
getHTML(applicant, xpath, b) {
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
return selector.getHTML(b);
|
|
719
|
-
});
|
|
646
|
+
async getHTML(applicant, xpath, b) {
|
|
647
|
+
await this.createClient(applicant);
|
|
648
|
+
const client = this.getBrowserClient(applicant);
|
|
649
|
+
const selector = await client.$(xpath);
|
|
650
|
+
return selector.getHTML(b);
|
|
720
651
|
}
|
|
721
|
-
getCurrentTabId(applicant) {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
return client.getWindowHandle();
|
|
726
|
-
});
|
|
652
|
+
async getCurrentTabId(applicant) {
|
|
653
|
+
await this.createClient(applicant);
|
|
654
|
+
const client = this.getBrowserClient(applicant);
|
|
655
|
+
return client.getWindowHandle();
|
|
727
656
|
}
|
|
728
|
-
getTabIds(applicant) {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
return client.getWindowHandles();
|
|
733
|
-
});
|
|
657
|
+
async getTabIds(applicant) {
|
|
658
|
+
await this.createClient(applicant);
|
|
659
|
+
const client = this.getBrowserClient(applicant);
|
|
660
|
+
return client.getWindowHandles();
|
|
734
661
|
}
|
|
735
662
|
// @deprecated
|
|
736
|
-
windowHandles(applicant) {
|
|
737
|
-
return
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
return
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
return
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
return
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
return
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
gridTestSession(applicant) {
|
|
875
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
876
|
-
yield this.createClient(applicant);
|
|
877
|
-
const client = this.getBrowserClient(applicant);
|
|
878
|
-
if (this.localSelenium) {
|
|
879
|
-
return {
|
|
880
|
-
sessionId: client.sessionId,
|
|
881
|
-
host: this.config.host,
|
|
882
|
-
port: this.config.port,
|
|
883
|
-
localSelenium: true,
|
|
884
|
-
};
|
|
885
|
-
}
|
|
886
|
-
return client.gridTestSession(client.sessionId);
|
|
887
|
-
});
|
|
888
|
-
}
|
|
889
|
-
getHubConfig(applicant) {
|
|
890
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
891
|
-
yield this.createClient(applicant);
|
|
892
|
-
const client = this.getBrowserClient(applicant);
|
|
893
|
-
if (this.localSelenium) {
|
|
894
|
-
return {
|
|
895
|
-
sessionId: client.sessionId,
|
|
896
|
-
host: this.config.host,
|
|
897
|
-
port: this.config.port,
|
|
898
|
-
localSelenium: true,
|
|
899
|
-
};
|
|
900
|
-
}
|
|
901
|
-
return client.getHubConfig();
|
|
902
|
-
});
|
|
663
|
+
async windowHandles(applicant) {
|
|
664
|
+
return this.getTabIds(applicant);
|
|
665
|
+
}
|
|
666
|
+
async window(applicant, tabId) {
|
|
667
|
+
await this.createClient(applicant);
|
|
668
|
+
const client = this.getBrowserClient(applicant);
|
|
669
|
+
return client.switchToWindow(tabId);
|
|
670
|
+
}
|
|
671
|
+
async switchTab(applicant, tabId) {
|
|
672
|
+
await this.createClient(applicant);
|
|
673
|
+
const client = this.getBrowserClient(applicant);
|
|
674
|
+
const result = await client.switchToWindow(tabId);
|
|
675
|
+
const body = await client.$('body');
|
|
676
|
+
await client.waitUntil(async () => body.isExisting(), { timeout: 10000 });
|
|
677
|
+
return result;
|
|
678
|
+
}
|
|
679
|
+
async close(applicant, tabId) {
|
|
680
|
+
await this.createClient(applicant);
|
|
681
|
+
const client = this.getBrowserClient(applicant);
|
|
682
|
+
const tabs = await this.getTabIds(applicant);
|
|
683
|
+
if (tabs.length === 1 && tabs[0] === tabId) {
|
|
684
|
+
return this.end(applicant);
|
|
685
|
+
}
|
|
686
|
+
await client.switchToWindow(tabId);
|
|
687
|
+
return client.closeWindow();
|
|
688
|
+
}
|
|
689
|
+
async getTagName(applicant, xpath) {
|
|
690
|
+
await this.createClient(applicant);
|
|
691
|
+
const client = this.getBrowserClient(applicant);
|
|
692
|
+
const selector = await client.$(xpath);
|
|
693
|
+
return selector.getTagName();
|
|
694
|
+
}
|
|
695
|
+
async isSelected(applicant, xpath) {
|
|
696
|
+
await this.createClient(applicant);
|
|
697
|
+
const client = this.getBrowserClient(applicant);
|
|
698
|
+
const selector = await client.$(xpath);
|
|
699
|
+
return selector.isSelected();
|
|
700
|
+
}
|
|
701
|
+
async getText(applicant, xpath) {
|
|
702
|
+
await this.createClient(applicant);
|
|
703
|
+
const client = this.getBrowserClient(applicant);
|
|
704
|
+
const selector = await client.$(xpath);
|
|
705
|
+
return selector.getText();
|
|
706
|
+
}
|
|
707
|
+
async elementIdSelected(applicant, id) {
|
|
708
|
+
await this.createClient(applicant);
|
|
709
|
+
const client = this.getBrowserClient(applicant);
|
|
710
|
+
return client.isElementSelected(id);
|
|
711
|
+
}
|
|
712
|
+
async makeScreenshot(applicant) {
|
|
713
|
+
await this.createClient(applicant);
|
|
714
|
+
const client = this.getBrowserClient(applicant);
|
|
715
|
+
return client.takeScreenshot();
|
|
716
|
+
}
|
|
717
|
+
async uploadFile(applicant, filePath) {
|
|
718
|
+
await this.createClient(applicant);
|
|
719
|
+
const client = this.getBrowserClient(applicant);
|
|
720
|
+
return client.uploadFile(filePath);
|
|
721
|
+
}
|
|
722
|
+
async getCssProperty(applicant, xpath, cssProperty) {
|
|
723
|
+
await this.createClient(applicant);
|
|
724
|
+
const client = this.getBrowserClient(applicant);
|
|
725
|
+
const element = await client.$(xpath);
|
|
726
|
+
const property = await element.getCSSProperty(cssProperty);
|
|
727
|
+
return property.value;
|
|
728
|
+
}
|
|
729
|
+
async getSource(applicant) {
|
|
730
|
+
await this.createClient(applicant);
|
|
731
|
+
const client = this.getBrowserClient(applicant);
|
|
732
|
+
return client.getPageSource();
|
|
733
|
+
}
|
|
734
|
+
async isExisting(applicant, xpath) {
|
|
735
|
+
await this.createClient(applicant);
|
|
736
|
+
const client = this.getBrowserClient(applicant);
|
|
737
|
+
const selector = await client.$(xpath);
|
|
738
|
+
return selector.isExisting();
|
|
739
|
+
}
|
|
740
|
+
async waitForValue(applicant, xpath, timeout, reverse) {
|
|
741
|
+
await this.createClient(applicant);
|
|
742
|
+
const client = this.getBrowserClient(applicant);
|
|
743
|
+
return client.waitUntil(async () => {
|
|
744
|
+
const elemValue = await (await client.$(xpath)).getValue();
|
|
745
|
+
return reverse ? !elemValue : !!elemValue;
|
|
746
|
+
}, { timeout });
|
|
747
|
+
}
|
|
748
|
+
async waitForSelected(applicant, xpath, timeout, reverse) {
|
|
749
|
+
await this.createClient(applicant);
|
|
750
|
+
const client = this.getBrowserClient(applicant);
|
|
751
|
+
return client.waitUntil(async () => {
|
|
752
|
+
const isSelected = await (await client.$(xpath)).isSelected();
|
|
753
|
+
return reverse ? !isSelected : isSelected;
|
|
754
|
+
}, { timeout });
|
|
755
|
+
}
|
|
756
|
+
async waitUntil(applicant, condition, timeout, timeoutMsg, interval) {
|
|
757
|
+
await this.createClient(applicant);
|
|
758
|
+
const client = this.getBrowserClient(applicant);
|
|
759
|
+
const options = {
|
|
760
|
+
timeout: timeout || 5000,
|
|
761
|
+
};
|
|
762
|
+
if (timeoutMsg !== undefined) {
|
|
763
|
+
options.timeoutMsg = timeoutMsg;
|
|
764
|
+
}
|
|
765
|
+
if (interval !== undefined) {
|
|
766
|
+
options.interval = interval;
|
|
767
|
+
}
|
|
768
|
+
return client.waitUntil(condition, options);
|
|
769
|
+
}
|
|
770
|
+
async selectByAttribute(applicant, xpath, attribute, value) {
|
|
771
|
+
await this.createClient(applicant);
|
|
772
|
+
const client = this.getBrowserClient(applicant);
|
|
773
|
+
const selector = await client.$(xpath);
|
|
774
|
+
return selector.selectByAttribute(attribute, value);
|
|
775
|
+
}
|
|
776
|
+
async gridTestSession(applicant) {
|
|
777
|
+
await this.createClient(applicant);
|
|
778
|
+
const client = this.getBrowserClient(applicant);
|
|
779
|
+
if (this.localSelenium) {
|
|
780
|
+
return {
|
|
781
|
+
sessionId: client.sessionId,
|
|
782
|
+
host: this.config.host,
|
|
783
|
+
port: this.config.port,
|
|
784
|
+
localSelenium: true,
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
return client.gridTestSession(client.sessionId);
|
|
788
|
+
}
|
|
789
|
+
async getHubConfig(applicant) {
|
|
790
|
+
await this.createClient(applicant);
|
|
791
|
+
const client = this.getBrowserClient(applicant);
|
|
792
|
+
if (this.localSelenium) {
|
|
793
|
+
return {
|
|
794
|
+
sessionId: client.sessionId,
|
|
795
|
+
host: this.config.host,
|
|
796
|
+
port: this.config.port,
|
|
797
|
+
localSelenium: true,
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
return client.getHubConfig();
|
|
903
801
|
}
|
|
904
802
|
/**
|
|
905
803
|
* @param overwrites should NOT be an arrow function, Otherwise it would throw an error
|
|
906
804
|
*/
|
|
907
|
-
mock(applicant, url, overwrites, filterOptions, mockResponseParams) {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
mobileEmulation: {
|
|
925
|
-
deviceName,
|
|
926
|
-
},
|
|
805
|
+
async mock(applicant, url, overwrites, filterOptions, mockResponseParams) {
|
|
806
|
+
await this.createClient(applicant);
|
|
807
|
+
const client = this.getBrowserClient(applicant);
|
|
808
|
+
const mock = await client.mock(url, filterOptions);
|
|
809
|
+
mock.respond(overwrites, mockResponseParams);
|
|
810
|
+
}
|
|
811
|
+
async emulateDevice(applicant, deviceName) {
|
|
812
|
+
await this.createClient(applicant);
|
|
813
|
+
const client = this.getBrowserClient(applicant);
|
|
814
|
+
await client.deleteSession();
|
|
815
|
+
this.browserClients.delete(applicant);
|
|
816
|
+
this.customBrowserClientsConfigs.delete(applicant);
|
|
817
|
+
await this.createClient(applicant, {
|
|
818
|
+
capabilities: {
|
|
819
|
+
'goog:chromeOptions': {
|
|
820
|
+
mobileEmulation: {
|
|
821
|
+
deviceName,
|
|
927
822
|
},
|
|
928
823
|
},
|
|
929
|
-
}
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
status(applicant) {
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
return
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
return
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
isFocused(applicant, xpath) {
|
|
1023
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1024
|
-
yield this.createClient(applicant);
|
|
1025
|
-
const client = this.getBrowserClient(applicant);
|
|
1026
|
-
const selector = yield client.$(xpath);
|
|
1027
|
-
return selector.isFocused();
|
|
1028
|
-
});
|
|
1029
|
-
}
|
|
1030
|
-
isStable(applicant, xpath) {
|
|
1031
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1032
|
-
yield this.createClient(applicant);
|
|
1033
|
-
const client = this.getBrowserClient(applicant);
|
|
1034
|
-
const selector = yield client.$(xpath);
|
|
1035
|
-
return selector.isStable();
|
|
1036
|
-
});
|
|
1037
|
-
}
|
|
1038
|
-
waitForEnabled(applicant, xpath, timeout) {
|
|
1039
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1040
|
-
yield this.createClient(applicant);
|
|
1041
|
-
const client = this.getBrowserClient(applicant);
|
|
1042
|
-
const selector = yield client.$(xpath);
|
|
1043
|
-
return selector.waitForEnabled({ timeout });
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
|
-
waitForStable(applicant, xpath, timeout) {
|
|
1047
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1048
|
-
yield this.createClient(applicant);
|
|
1049
|
-
const client = this.getBrowserClient(applicant);
|
|
1050
|
-
const selector = yield client.$(xpath);
|
|
1051
|
-
return selector.waitForStable({ timeout });
|
|
1052
|
-
});
|
|
824
|
+
},
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
async status(applicant) {
|
|
828
|
+
await this.createClient(applicant);
|
|
829
|
+
const client = this.getBrowserClient(applicant);
|
|
830
|
+
return client.status();
|
|
831
|
+
}
|
|
832
|
+
async back(applicant) {
|
|
833
|
+
await this.createClient(applicant);
|
|
834
|
+
const client = this.getBrowserClient(applicant);
|
|
835
|
+
return client.back();
|
|
836
|
+
}
|
|
837
|
+
async forward(applicant) {
|
|
838
|
+
await this.createClient(applicant);
|
|
839
|
+
const client = this.getBrowserClient(applicant);
|
|
840
|
+
return client.forward();
|
|
841
|
+
}
|
|
842
|
+
async getActiveElement(applicant) {
|
|
843
|
+
await this.createClient(applicant);
|
|
844
|
+
const client = this.getBrowserClient(applicant);
|
|
845
|
+
return client.getActiveElement();
|
|
846
|
+
}
|
|
847
|
+
async getLocation(applicant, xpath) {
|
|
848
|
+
await this.createClient(applicant);
|
|
849
|
+
const client = this.getBrowserClient(applicant);
|
|
850
|
+
const element = client.$(xpath);
|
|
851
|
+
return element.getLocation();
|
|
852
|
+
}
|
|
853
|
+
async setTimeZone(applicant, timeZone) {
|
|
854
|
+
await this.createClient(applicant);
|
|
855
|
+
const client = this.getBrowserClient(applicant);
|
|
856
|
+
return client.setTimeZone(timeZone);
|
|
857
|
+
}
|
|
858
|
+
async getWindowSize(applicant) {
|
|
859
|
+
await this.createClient(applicant);
|
|
860
|
+
const client = this.getBrowserClient(applicant);
|
|
861
|
+
return client.getWindowSize();
|
|
862
|
+
}
|
|
863
|
+
async savePDF(applicant, options) {
|
|
864
|
+
await this.createClient(applicant);
|
|
865
|
+
const client = this.getBrowserClient(applicant);
|
|
866
|
+
const { filepath, ...restOptions } = options;
|
|
867
|
+
return client.savePDF(filepath, restOptions);
|
|
868
|
+
}
|
|
869
|
+
async addValue(applicant, xpath, value) {
|
|
870
|
+
await this.createClient(applicant);
|
|
871
|
+
const client = this.getBrowserClient(applicant);
|
|
872
|
+
const selector = await client.$(xpath);
|
|
873
|
+
return selector.addValue(value);
|
|
874
|
+
}
|
|
875
|
+
async doubleClick(applicant, xpath) {
|
|
876
|
+
await this.createClient(applicant);
|
|
877
|
+
const client = this.getBrowserClient(applicant);
|
|
878
|
+
const selector = await client.$(xpath);
|
|
879
|
+
return selector.doubleClick();
|
|
880
|
+
}
|
|
881
|
+
async isClickable(applicant, xpath) {
|
|
882
|
+
await this.createClient(applicant);
|
|
883
|
+
const client = this.getBrowserClient(applicant);
|
|
884
|
+
const selector = await client.$(xpath);
|
|
885
|
+
return selector.isClickable();
|
|
886
|
+
}
|
|
887
|
+
async waitForClickable(applicant, xpath, timeout) {
|
|
888
|
+
await this.createClient(applicant);
|
|
889
|
+
const client = this.getBrowserClient(applicant);
|
|
890
|
+
const selector = await client.$(xpath);
|
|
891
|
+
return selector.waitForClickable({ timeout });
|
|
892
|
+
}
|
|
893
|
+
async isFocused(applicant, xpath) {
|
|
894
|
+
await this.createClient(applicant);
|
|
895
|
+
const client = this.getBrowserClient(applicant);
|
|
896
|
+
const selector = await client.$(xpath);
|
|
897
|
+
return selector.isFocused();
|
|
898
|
+
}
|
|
899
|
+
async isStable(applicant, xpath) {
|
|
900
|
+
await this.createClient(applicant);
|
|
901
|
+
const client = this.getBrowserClient(applicant);
|
|
902
|
+
const selector = await client.$(xpath);
|
|
903
|
+
return selector.isStable();
|
|
904
|
+
}
|
|
905
|
+
async waitForEnabled(applicant, xpath, timeout) {
|
|
906
|
+
await this.createClient(applicant);
|
|
907
|
+
const client = this.getBrowserClient(applicant);
|
|
908
|
+
const selector = await client.$(xpath);
|
|
909
|
+
return selector.waitForEnabled({ timeout });
|
|
910
|
+
}
|
|
911
|
+
async waitForStable(applicant, xpath, timeout) {
|
|
912
|
+
await this.createClient(applicant);
|
|
913
|
+
const client = this.getBrowserClient(applicant);
|
|
914
|
+
const selector = await client.$(xpath);
|
|
915
|
+
return selector.waitForStable({ timeout });
|
|
1053
916
|
}
|
|
1054
917
|
}
|
|
1055
918
|
exports.SeleniumPlugin = SeleniumPlugin;
|