@midscene/webdriver 1.8.4-beta-20260521070317.0 → 1.8.4
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/es/index.mjs +9 -0
- package/dist/lib/index.js +9 -0
- package/dist/types/index.d.ts +7 -0
- package/package.json +2 -2
package/dist/es/index.mjs
CHANGED
|
@@ -213,6 +213,7 @@ class WebDriverClient {
|
|
|
213
213
|
}
|
|
214
214
|
});
|
|
215
215
|
this.sessionId = response.sessionId || response.value?.sessionId;
|
|
216
|
+
this.ownsSession = true;
|
|
216
217
|
if (!this.sessionId) throw new Error('Failed to get session ID from response');
|
|
217
218
|
debugClient(`Created session: ${this.sessionId}`);
|
|
218
219
|
return {
|
|
@@ -226,6 +227,11 @@ class WebDriverClient {
|
|
|
226
227
|
}
|
|
227
228
|
async deleteSession() {
|
|
228
229
|
if (!this.sessionId) return void debugClient('No active session to delete');
|
|
230
|
+
if (!this.ownsSession) {
|
|
231
|
+
debugClient(`Detached external session: ${this.sessionId}`);
|
|
232
|
+
this.sessionId = null;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
229
235
|
try {
|
|
230
236
|
await this.makeRequest('DELETE', `/session/${this.sessionId}`);
|
|
231
237
|
debugClient(`Deleted session: ${this.sessionId}`);
|
|
@@ -292,6 +298,7 @@ class WebDriverClient {
|
|
|
292
298
|
constructor(options = {}){
|
|
293
299
|
WebDriverClient_define_property(this, "baseUrl", void 0);
|
|
294
300
|
WebDriverClient_define_property(this, "sessionId", null);
|
|
301
|
+
WebDriverClient_define_property(this, "ownsSession", false);
|
|
295
302
|
WebDriverClient_define_property(this, "port", void 0);
|
|
296
303
|
WebDriverClient_define_property(this, "host", void 0);
|
|
297
304
|
WebDriverClient_define_property(this, "timeout", void 0);
|
|
@@ -299,6 +306,8 @@ class WebDriverClient {
|
|
|
299
306
|
this.host = options.host || 'localhost';
|
|
300
307
|
this.timeout = options.timeout || 30000;
|
|
301
308
|
this.baseUrl = `http://${this.host}:${this.port}`;
|
|
309
|
+
this.sessionId = options.sessionId || null;
|
|
310
|
+
this.ownsSession = !options.sessionId;
|
|
302
311
|
debugClient(`Initialized WebDriver client on ${this.host}:${this.port}`);
|
|
303
312
|
}
|
|
304
313
|
}
|
package/dist/lib/index.js
CHANGED
|
@@ -245,6 +245,7 @@ class WebDriverClient {
|
|
|
245
245
|
}
|
|
246
246
|
});
|
|
247
247
|
this.sessionId = response.sessionId || response.value?.sessionId;
|
|
248
|
+
this.ownsSession = true;
|
|
248
249
|
if (!this.sessionId) throw new Error('Failed to get session ID from response');
|
|
249
250
|
debugClient(`Created session: ${this.sessionId}`);
|
|
250
251
|
return {
|
|
@@ -258,6 +259,11 @@ class WebDriverClient {
|
|
|
258
259
|
}
|
|
259
260
|
async deleteSession() {
|
|
260
261
|
if (!this.sessionId) return void debugClient('No active session to delete');
|
|
262
|
+
if (!this.ownsSession) {
|
|
263
|
+
debugClient(`Detached external session: ${this.sessionId}`);
|
|
264
|
+
this.sessionId = null;
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
261
267
|
try {
|
|
262
268
|
await this.makeRequest('DELETE', `/session/${this.sessionId}`);
|
|
263
269
|
debugClient(`Deleted session: ${this.sessionId}`);
|
|
@@ -324,6 +330,7 @@ class WebDriverClient {
|
|
|
324
330
|
constructor(options = {}){
|
|
325
331
|
WebDriverClient_define_property(this, "baseUrl", void 0);
|
|
326
332
|
WebDriverClient_define_property(this, "sessionId", null);
|
|
333
|
+
WebDriverClient_define_property(this, "ownsSession", false);
|
|
327
334
|
WebDriverClient_define_property(this, "port", void 0);
|
|
328
335
|
WebDriverClient_define_property(this, "host", void 0);
|
|
329
336
|
WebDriverClient_define_property(this, "timeout", void 0);
|
|
@@ -331,6 +338,8 @@ class WebDriverClient {
|
|
|
331
338
|
this.host = options.host || 'localhost';
|
|
332
339
|
this.timeout = options.timeout || 30000;
|
|
333
340
|
this.baseUrl = `http://${this.host}:${this.port}`;
|
|
341
|
+
this.sessionId = options.sessionId || null;
|
|
342
|
+
this.ownsSession = !options.sessionId;
|
|
334
343
|
debugClient(`Initialized WebDriver client on ${this.host}:${this.port}`);
|
|
335
344
|
}
|
|
336
345
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ export declare interface WDASession {
|
|
|
82
82
|
export declare class WebDriverClient {
|
|
83
83
|
protected baseUrl: string;
|
|
84
84
|
protected sessionId: string | null;
|
|
85
|
+
protected ownsSession: boolean;
|
|
85
86
|
protected port: number;
|
|
86
87
|
protected host: string;
|
|
87
88
|
protected timeout: number;
|
|
@@ -106,6 +107,12 @@ export declare interface WebDriverOptions {
|
|
|
106
107
|
port?: number;
|
|
107
108
|
host?: string;
|
|
108
109
|
timeout?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Existing WebDriver session ID to attach to instead of creating a new one.
|
|
112
|
+
* Sessions provided by the caller are detached locally on cleanup and are not
|
|
113
|
+
* deleted from the remote WebDriver server.
|
|
114
|
+
*/
|
|
115
|
+
sessionId?: string;
|
|
109
116
|
}
|
|
110
117
|
|
|
111
118
|
export declare class WebDriverRequestError extends Error {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/webdriver",
|
|
3
|
-
"version": "1.8.4
|
|
3
|
+
"version": "1.8.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/midscene.git",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"types": "dist/types/index.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"node-fetch": "^3.3.2",
|
|
15
|
-
"@midscene/shared": "1.8.4
|
|
15
|
+
"@midscene/shared": "1.8.4"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@rslib/core": "^0.18.3",
|