@dev-blinq/cucumber_client 1.0.1519-dev → 1.0.1521-dev

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.
@@ -352,6 +352,15 @@ export class BVTRecorder {
352
352
  this.web.tryAllStrategies = true;
353
353
  this.page = bvtContext.page;
354
354
  this.pageSet.add(this.page);
355
+ if (process.env.REMOTE_RECORDER === "true") {
356
+ this.remoteBrowser = new RemoteBrowserService({
357
+ CDP_CONNECT_URL: `http://localhost:${this.#remoteDebuggerPort}`,
358
+ currentPage: this.page,
359
+ });
360
+ this.remoteBrowser.on("debugURLChange", (url) => {
361
+ this.sendEvent(this.events.onDebugURLChange, url);
362
+ });
363
+ }
355
364
  this.lastKnownUrlPath = this._updateUrlPath();
356
365
  const browser = await this.context.browser();
357
366
  this.browser = browser;
@@ -403,15 +412,6 @@ export class BVTRecorder {
403
412
  // add listeners for new pages
404
413
  this._addPagelisteners(this.context);
405
414
 
406
- if (process.env.REMOTE_RECORDER === "true") {
407
- this.remoteBrowser = new RemoteBrowserService({
408
- CDP_CONNECT_URL: `http://localhost:${this.#remoteDebuggerPort}`,
409
- currentPage: this.page,
410
- });
411
- this.remoteBrowser.on("debugURLChange", (url) => {
412
- this.sendEvent(this.events.onDebugURLChange, url);
413
- });
414
- }
415
415
  await this.page.goto(url, {
416
416
  waitUntil: "domcontentloaded",
417
417
  });
@@ -631,6 +631,7 @@ export class BVTRecorder {
631
631
 
632
632
  _addPagelisteners(context) {
633
633
  context.on("page", async (page) => {
634
+ console.log("New page opened");
634
635
  try {
635
636
  if (page.isClosed()) return;
636
637
  this.pageSet.add(page);
@@ -150,47 +150,33 @@ export class NamesService {
150
150
  }
151
151
  export class RemoteBrowserService extends EventEmitter {
152
152
  CDP_CONNECT_URL;
153
- pageMap = new Map();
154
153
  _selectedPage;
155
154
  logger = socketLogger;
156
155
  constructor({ CDP_CONNECT_URL, currentPage }) {
157
156
  super();
158
157
  this.CDP_CONNECT_URL = CDP_CONNECT_URL;
159
158
  this._selectedPage = currentPage;
160
- this.getDebugURLs()
161
- .then((debugData) => {
162
- debugData.forEach((page) => {
163
- if (page.type === "page") {
164
- this.pageMap.set(page.url, page.id);
159
+ this.emitSelectedPageId();
160
+ }
161
+ async emitSelectedPageId() {
162
+ let id = null;
163
+ try {
164
+ const debugData = await this.getDebugURLs();
165
+ for (const pageData of debugData) {
166
+ if (pageData.type === "page" && pageData.url === this._selectedPage.url()) {
167
+ id = pageData.id;
168
+ break;
165
169
  }
166
- });
167
- })
168
- .catch((error) => {
169
- this.logger.error("Error fetching debug URLs: ", error instanceof Error ? error.message : error);
170
- });
170
+ }
171
+ this.emit("debugURLChange", id);
172
+ }
173
+ catch (error) {
174
+ this.logger.error("Error fetching debug URLs: ", error instanceof Error ? error.message : JSON.stringify(error));
175
+ }
171
176
  }
172
177
  set selectedPage(page) {
173
178
  this._selectedPage = page;
174
- const pageUrl = page.url();
175
- const pageEntry = this.pageMap.get(pageUrl);
176
- if (!pageEntry) {
177
- this.getDebugURLs()
178
- .then((debugData) => {
179
- console.log("Fetched debug data: ", debugData);
180
- debugData.forEach((page) => {
181
- this.pageMap.set(page.url, page.id);
182
- });
183
- const url = this.pageMap.get(pageUrl);
184
- this.emit("debugURLChange", url);
185
- })
186
- .catch((error) => {
187
- this.logger.error("Error fetching debug URLs: ", error instanceof Error ? error.message : JSON.stringify(error));
188
- });
189
- }
190
- else {
191
- const url = this.pageMap.get(pageUrl);
192
- this.emit("debugURLChange", url);
193
- }
179
+ this.emitSelectedPageId();
194
180
  }
195
181
  get selectedPage() {
196
182
  return this._selectedPage;
@@ -203,7 +189,6 @@ export class RemoteBrowserService extends EventEmitter {
203
189
  });
204
190
  if (response.status !== 200) {
205
191
  throw new Error("Error while fetching debug URL");
206
- return [];
207
192
  }
208
193
  return response.data;
209
194
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-blinq/cucumber_client",
3
- "version": "1.0.1519-dev",
3
+ "version": "1.0.1521-dev",
4
4
  "description": " ",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  "@cucumber/tag-expressions": "^6.1.1",
40
40
  "@dev-blinq/cucumber-js": "1.0.195-dev",
41
41
  "@faker-js/faker": "^8.4.1",
42
- "automation_model": "1.0.870-dev",
42
+ "automation_model": "1.0.871-dev",
43
43
  "axios": "^1.7.4",
44
44
  "chokidar": "^3.6.0",
45
45
  "create-require": "^1.1.1",