@testring/plugin-selenium-driver 0.7.6 → 0.8.1
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 +744 -891
- 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 +40 -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;
|
|
@@ -77,15 +83,16 @@ class SeleniumPlugin {
|
|
|
77
83
|
}
|
|
78
84
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
79
85
|
createConfig(config) {
|
|
80
|
-
var _a
|
|
86
|
+
var _a;
|
|
81
87
|
const mergedConfig = deepmerge.all([DEFAULT_CONFIG, config], {
|
|
82
88
|
clone: true,
|
|
83
89
|
});
|
|
84
90
|
if (!mergedConfig.hostname && mergedConfig.host) {
|
|
85
91
|
mergedConfig.hostname = mergedConfig.host;
|
|
86
92
|
}
|
|
87
|
-
const
|
|
88
|
-
|
|
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')) {
|
|
89
96
|
const extensions = googleChromeOptions.extensions;
|
|
90
97
|
const dowldMonitorCrx = (0, dwnld_collector_crx_1.getCrxBase64)();
|
|
91
98
|
if (extensions) {
|
|
@@ -130,44 +137,41 @@ class SeleniumPlugin {
|
|
|
130
137
|
}
|
|
131
138
|
return [`-Dwebdriver.chrome.driver=${chromeDriverPath}`];
|
|
132
139
|
}
|
|
133
|
-
runLocalSelenium() {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
this.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
});
|
|
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
|
+
}
|
|
165
171
|
}
|
|
166
172
|
getApplicantSessionId(applicant) {
|
|
167
173
|
const item = this.browserClients.get(applicant);
|
|
168
|
-
|
|
169
|
-
return item.sessionId;
|
|
170
|
-
}
|
|
174
|
+
return item === null || item === void 0 ? void 0 : item.sessionId;
|
|
171
175
|
}
|
|
172
176
|
hasBrowserClient(applicant) {
|
|
173
177
|
return this.browserClients.has(applicant);
|
|
@@ -179,44 +183,38 @@ class SeleniumPlugin {
|
|
|
179
183
|
}
|
|
180
184
|
throw new Error('Browser client is not found');
|
|
181
185
|
}
|
|
182
|
-
pingClients() {
|
|
183
|
-
|
|
184
|
-
|
|
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`);
|
|
185
201
|
try {
|
|
186
|
-
|
|
202
|
+
await this.end(applicant);
|
|
187
203
|
}
|
|
188
204
|
catch (e) {
|
|
189
|
-
|
|
205
|
+
this.logger.error(`Session applicant ${applicant} failed to stop`, e);
|
|
190
206
|
}
|
|
207
|
+
this.expiredBrowserClients.add(applicant);
|
|
191
208
|
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
closeExpiredClients() {
|
|
195
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
-
const timeLimit = Date.now() - this.config.clientTimeout;
|
|
197
|
-
for (const [applicant, clientData] of this.browserClients) {
|
|
198
|
-
if (clientData.initTime < timeLimit) {
|
|
199
|
-
this.logger.warn(`Session applicant ${applicant} marked as expired`);
|
|
200
|
-
try {
|
|
201
|
-
yield this.end(applicant);
|
|
202
|
-
}
|
|
203
|
-
catch (e) {
|
|
204
|
-
this.logger.error(`Session applicant ${applicant} failed to stop`, e);
|
|
205
|
-
}
|
|
206
|
-
this.expiredBrowserClients.add(applicant);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
});
|
|
209
|
+
}
|
|
210
210
|
}
|
|
211
|
-
checkClientsTimeout() {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
});
|
|
211
|
+
async checkClientsTimeout() {
|
|
212
|
+
if (this.config.clientTimeout === 0) {
|
|
213
|
+
await this.pingClients();
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
await this.closeExpiredClients();
|
|
217
|
+
}
|
|
220
218
|
}
|
|
221
219
|
setCustomBrowserClientConfig(applicant, config) {
|
|
222
220
|
this.customBrowserClientsConfigs.set(applicant, config);
|
|
@@ -224,842 +222,697 @@ class SeleniumPlugin {
|
|
|
224
222
|
getCustomBrowserClientConfig(applicant) {
|
|
225
223
|
return this.customBrowserClientsConfigs.get(applicant);
|
|
226
224
|
}
|
|
227
|
-
createClient(applicant, config) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (clientData) {
|
|
232
|
-
this.browserClients.set(applicant, Object.assign(Object.assign({}, clientData), { initTime: Date.now() }));
|
|
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 = yield (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 = yield this.enableCDPCoverageClient(client);
|
|
257
|
-
this.logger.debug('ended to init cdp coverage....');
|
|
258
|
-
}
|
|
225
|
+
async createClient(applicant, config) {
|
|
226
|
+
await this.waitForReadyState;
|
|
227
|
+
const clientData = this.browserClients.get(applicant);
|
|
228
|
+
if (clientData) {
|
|
259
229
|
this.browserClients.set(applicant, {
|
|
260
|
-
|
|
261
|
-
sessionId,
|
|
230
|
+
...clientData,
|
|
262
231
|
initTime: Date.now(),
|
|
263
|
-
cdpCoverageCollector: cdpCoverageCollector
|
|
264
|
-
? cdpCoverageCollector
|
|
265
|
-
: null,
|
|
266
232
|
});
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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,
|
|
286
266
|
});
|
|
267
|
+
this.logger.debug(`Started session for applicant: ${applicant}. Session id: ${sessionId}`);
|
|
287
268
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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))];
|
|
303
298
|
}
|
|
304
299
|
addCustromMethods(client) {
|
|
305
300
|
return client;
|
|
306
301
|
}
|
|
307
|
-
end(applicant) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
yield attachedClient.deleteSession();
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
catch (err) {
|
|
339
|
-
this.logger.error(`Old session ${startingSessionID} delete error`, err);
|
|
340
|
-
}
|
|
341
|
-
try {
|
|
342
|
-
yield client.deleteSession();
|
|
343
|
-
}
|
|
344
|
-
catch (err) {
|
|
345
|
-
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();
|
|
346
330
|
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
yield delay(this.config.delayAfterSessionClose);
|
|
352
|
-
}
|
|
353
|
-
this.browserClients.delete(applicant);
|
|
354
|
-
this.customBrowserClientsConfigs.delete(applicant);
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
kill() {
|
|
358
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
359
|
-
var _a, _b, _c, _d;
|
|
360
|
-
this.logger.debug('Kill command is called');
|
|
361
|
-
// Close all browser sessions
|
|
362
|
-
for (const applicant of this.browserClients.keys()) {
|
|
331
|
+
}
|
|
332
|
+
catch (err) {
|
|
333
|
+
this.logger.error(`Old session ${startingSessionID} delete error`, err);
|
|
334
|
+
}
|
|
363
335
|
try {
|
|
364
|
-
|
|
336
|
+
await client.deleteSession();
|
|
365
337
|
}
|
|
366
|
-
catch (
|
|
367
|
-
this.logger.error(
|
|
338
|
+
catch (err) {
|
|
339
|
+
this.logger.error(`New session ${client.sessionId} delete error`, err);
|
|
368
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);
|
|
369
357
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
yield this.stopAllSessions();
|
|
358
|
+
catch (e) {
|
|
359
|
+
this.logger.error(e);
|
|
373
360
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
(
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
this.logger.warn(`Selenium did not exit in time. Sending SIGKILL.`);
|
|
399
|
-
this.localSelenium.kill('SIGKILL');
|
|
400
|
-
}
|
|
401
|
-
resolve();
|
|
402
|
-
}, 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();
|
|
403
385
|
});
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
yield this.createClient(applicant);
|
|
421
|
-
const client = this.getBrowserClient(applicant);
|
|
422
|
-
const element = yield client.$(selector);
|
|
423
|
-
return options && Object.keys(options).length > 0
|
|
424
|
-
? element.click(options)
|
|
425
|
-
: element.click();
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
getSize(applicant, selector) {
|
|
429
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
430
|
-
yield this.createClient(applicant);
|
|
431
|
-
const client = this.getBrowserClient(applicant);
|
|
432
|
-
const element = yield client.$(selector);
|
|
433
|
-
return element.getSize();
|
|
434
|
-
});
|
|
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
|
+
}
|
|
435
402
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
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);
|
|
445
429
|
}
|
|
446
430
|
generateWinId() {
|
|
447
431
|
this.incrementWinId++;
|
|
448
432
|
return `window-${this.incrementWinId}`;
|
|
449
433
|
}
|
|
450
|
-
newWindow(
|
|
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
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
return
|
|
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
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
return
|
|
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
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
return
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
windowHandleMaximize(applicant) {
|
|
611
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
612
|
-
yield this.createClient(applicant);
|
|
613
|
-
const client = this.getBrowserClient(applicant);
|
|
614
|
-
return client.maximizeWindow();
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
isEnabled(applicant, xpath) {
|
|
618
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
619
|
-
yield this.createClient(applicant);
|
|
620
|
-
const client = this.getBrowserClient(applicant);
|
|
621
|
-
const selector = yield client.$(xpath);
|
|
622
|
-
return selector.isEnabled();
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
scroll(applicant, xpath, xOffset, yOffset) {
|
|
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();
|
|
631
|
-
return element.moveTo({ xOffset, yOffset });
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
scrollIntoView(applicant, xpath, scrollIntoViewOptions) {
|
|
635
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
636
|
-
yield this.createClient(applicant);
|
|
637
|
-
const client = this.getBrowserClient(applicant);
|
|
638
|
-
const element = yield client.$(xpath);
|
|
639
|
-
yield element.scrollIntoView(scrollIntoViewOptions !== null ? scrollIntoViewOptions : undefined);
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
|
-
isAlertOpen(applicant) {
|
|
643
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
644
|
-
yield this.createClient(applicant);
|
|
645
|
-
const client = this.getBrowserClient(applicant);
|
|
646
|
-
return client.isAlertOpen();
|
|
647
|
-
});
|
|
648
|
-
}
|
|
649
|
-
alertAccept(applicant) {
|
|
650
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
651
|
-
yield this.createClient(applicant);
|
|
652
|
-
const client = this.getBrowserClient(applicant);
|
|
653
|
-
if (yield this.isAlertOpen(applicant)) {
|
|
654
|
-
return client.acceptAlert();
|
|
655
|
-
}
|
|
656
|
-
throw Error('There is no open alert');
|
|
657
|
-
});
|
|
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');
|
|
658
594
|
}
|
|
659
|
-
alertDismiss(applicant) {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
throw Error('There is no open alert');
|
|
667
|
-
});
|
|
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');
|
|
668
602
|
}
|
|
669
|
-
alertText(applicant) {
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
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;
|
|
675
631
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
}
|
|
679
|
-
dragAndDrop(applicant, xpathSource, xpathDestination) {
|
|
680
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
681
|
-
yield this.createClient(applicant);
|
|
682
|
-
const client = this.getBrowserClient(applicant);
|
|
683
|
-
const sourceElement = yield client.$(xpathSource);
|
|
684
|
-
const destinationElement = yield client.$(xpathDestination);
|
|
685
|
-
return sourceElement.dragAndDrop(destinationElement);
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
setCookie(applicant, cookieObj) {
|
|
689
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
690
|
-
yield this.createClient(applicant);
|
|
691
|
-
const client = this.getBrowserClient(applicant);
|
|
692
|
-
return yield client.setCookies(cookieObj);
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
getCookie(applicant, cookieName) {
|
|
696
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
697
|
-
var _a;
|
|
698
|
-
yield this.createClient(applicant);
|
|
699
|
-
const client = this.getBrowserClient(applicant);
|
|
700
|
-
if (cookieName) {
|
|
701
|
-
try {
|
|
702
|
-
const cookies = yield client.getCookies([cookieName]);
|
|
703
|
-
return (_a = cookies[0]) === null || _a === void 0 ? void 0 : _a.value;
|
|
704
|
-
}
|
|
705
|
-
catch (e) {
|
|
706
|
-
return undefined;
|
|
707
|
-
}
|
|
632
|
+
catch (e) {
|
|
633
|
+
return undefined;
|
|
708
634
|
}
|
|
709
|
-
|
|
710
|
-
|
|
635
|
+
}
|
|
636
|
+
return client.getAllCookies();
|
|
711
637
|
}
|
|
712
|
-
deleteCookie(applicant, cookieName) {
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
return client.deleteAllCookies();
|
|
720
|
-
});
|
|
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();
|
|
721
645
|
}
|
|
722
|
-
getHTML(applicant, xpath, b) {
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
return selector.getHTML(b);
|
|
728
|
-
});
|
|
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);
|
|
729
651
|
}
|
|
730
|
-
getCurrentTabId(applicant) {
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
return client.getWindowHandle();
|
|
735
|
-
});
|
|
652
|
+
async getCurrentTabId(applicant) {
|
|
653
|
+
await this.createClient(applicant);
|
|
654
|
+
const client = this.getBrowserClient(applicant);
|
|
655
|
+
return client.getWindowHandle();
|
|
736
656
|
}
|
|
737
|
-
getTabIds(applicant) {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
return client.getWindowHandles();
|
|
742
|
-
});
|
|
657
|
+
async getTabIds(applicant) {
|
|
658
|
+
await this.createClient(applicant);
|
|
659
|
+
const client = this.getBrowserClient(applicant);
|
|
660
|
+
return client.getWindowHandles();
|
|
743
661
|
}
|
|
744
662
|
// @deprecated
|
|
745
|
-
windowHandles(applicant) {
|
|
746
|
-
return
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
return
|
|
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
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
return
|
|
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
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
return
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
return
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
gridTestSession(applicant) {
|
|
884
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
885
|
-
yield this.createClient(applicant);
|
|
886
|
-
const client = this.getBrowserClient(applicant);
|
|
887
|
-
if (this.localSelenium) {
|
|
888
|
-
return {
|
|
889
|
-
sessionId: client.sessionId,
|
|
890
|
-
host: this.config.host,
|
|
891
|
-
port: this.config.port,
|
|
892
|
-
localSelenium: true,
|
|
893
|
-
};
|
|
894
|
-
}
|
|
895
|
-
return client.gridTestSession(client.sessionId);
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
|
-
getHubConfig(applicant) {
|
|
899
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
900
|
-
yield this.createClient(applicant);
|
|
901
|
-
const client = this.getBrowserClient(applicant);
|
|
902
|
-
if (this.localSelenium) {
|
|
903
|
-
return {
|
|
904
|
-
sessionId: client.sessionId,
|
|
905
|
-
host: this.config.host,
|
|
906
|
-
port: this.config.port,
|
|
907
|
-
localSelenium: true,
|
|
908
|
-
};
|
|
909
|
-
}
|
|
910
|
-
return client.getHubConfig();
|
|
911
|
-
});
|
|
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();
|
|
912
801
|
}
|
|
913
802
|
/**
|
|
914
803
|
* @param overwrites should NOT be an arrow function, Otherwise it would throw an error
|
|
915
804
|
*/
|
|
916
|
-
mock(applicant, url, overwrites, filterOptions, mockResponseParams) {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
'goog:chromeOptions': {
|
|
934
|
-
mobileEmulation: {
|
|
935
|
-
deviceName,
|
|
936
|
-
},
|
|
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,
|
|
937
822
|
},
|
|
938
823
|
},
|
|
939
|
-
}
|
|
940
|
-
});
|
|
941
|
-
}
|
|
942
|
-
status(applicant) {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
return
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
return
|
|
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
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
isFocused(applicant, xpath) {
|
|
1033
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1034
|
-
yield this.createClient(applicant);
|
|
1035
|
-
const client = this.getBrowserClient(applicant);
|
|
1036
|
-
const selector = yield client.$(xpath);
|
|
1037
|
-
return selector.isFocused();
|
|
1038
|
-
});
|
|
1039
|
-
}
|
|
1040
|
-
isStable(applicant, xpath) {
|
|
1041
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1042
|
-
yield this.createClient(applicant);
|
|
1043
|
-
const client = this.getBrowserClient(applicant);
|
|
1044
|
-
const selector = yield client.$(xpath);
|
|
1045
|
-
return selector.isStable();
|
|
1046
|
-
});
|
|
1047
|
-
}
|
|
1048
|
-
waitForEnabled(applicant, xpath, timeout) {
|
|
1049
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1050
|
-
yield this.createClient(applicant);
|
|
1051
|
-
const client = this.getBrowserClient(applicant);
|
|
1052
|
-
const selector = yield client.$(xpath);
|
|
1053
|
-
return selector.waitForEnabled({ timeout });
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1056
|
-
waitForStable(applicant, xpath, timeout) {
|
|
1057
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1058
|
-
yield this.createClient(applicant);
|
|
1059
|
-
const client = this.getBrowserClient(applicant);
|
|
1060
|
-
const selector = yield client.$(xpath);
|
|
1061
|
-
return selector.waitForStable({ timeout });
|
|
1062
|
-
});
|
|
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 });
|
|
1063
916
|
}
|
|
1064
917
|
}
|
|
1065
918
|
exports.SeleniumPlugin = SeleniumPlugin;
|