Skip to content

Commit edd6977

Browse files
committed
chore(web): print more debug logs for web page
1 parent f2695f7 commit edd6977

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

packages/web-integration/src/puppeteer/base-page.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,14 @@ export class Page<
195195
options?: { button?: MouseButton; count?: number },
196196
) => {
197197
await this.mouse.move(x, y);
198+
debugPage(`mouse click ${x}, ${y}`);
198199
this.underlyingPage.mouse.click(x, y, {
199200
button: options?.button || 'left',
200201
count: options?.count || 1,
201202
});
202203
},
203204
wheel: async (deltaX: number, deltaY: number) => {
205+
debugPage(`mouse wheel ${deltaX}, ${deltaY}`);
204206
if (this.pageType === 'puppeteer') {
205207
await (this.underlyingPage as PuppeteerPage).mouse.wheel({
206208
deltaX,
@@ -215,12 +217,14 @@ export class Page<
215217
},
216218
move: async (x: number, y: number) => {
217219
this.everMoved = true;
220+
debugPage(`mouse move to ${x}, ${y}`);
218221
return this.underlyingPage.mouse.move(x, y);
219222
},
220223
drag: async (
221224
from: { x: number; y: number },
222225
to: { x: number; y: number },
223226
) => {
227+
debugPage(`mouse drag from ${from.x}, ${from.y} to ${to.x}, ${to.y}`);
224228
if (this.pageType === 'puppeteer') {
225229
await (this.underlyingPage as PuppeteerPage).mouse.drag(
226230
{
@@ -248,15 +252,17 @@ export class Page<
248252

249253
get keyboard() {
250254
return {
251-
type: async (text: string) =>
252-
this.underlyingPage.keyboard.type(text, { delay: 80 }),
253-
255+
type: async (text: string) => {
256+
debugPage(`keyboard type ${text}`);
257+
this.underlyingPage.keyboard.type(text, { delay: 80 });
258+
},
254259
press: async (
255260
action:
256261
| { key: WebKeyInput; command?: string }
257262
| { key: WebKeyInput; command?: string }[],
258263
) => {
259264
const keys = Array.isArray(action) ? action : [action];
265+
debugPage('keyboard press', keys);
260266
for (const k of keys) {
261267
const commands = k.command ? [k.command] : [];
262268
await this.underlyingPage.keyboard.down(k.key, { commands });
@@ -266,9 +272,11 @@ export class Page<
266272
}
267273
},
268274
down: async (key: WebKeyInput) => {
275+
debugPage(`keyboard down ${key}`);
269276
this.underlyingPage.keyboard.down(key);
270277
},
271278
up: async (key: WebKeyInput) => {
279+
debugPage(`keyboard up ${key}`);
272280
this.underlyingPage.keyboard.up(key);
273281
},
274282
};
@@ -286,6 +294,7 @@ export class Page<
286294
};
287295

288296
const isMac = process.platform === 'darwin';
297+
debugPage('clearInput begin');
289298
if (isMac) {
290299
if (this.pageType === 'puppeteer') {
291300
// https://github.com/segment-boneyard/nightmare/issues/810#issuecomment-452669866
@@ -307,6 +316,7 @@ export class Page<
307316
await this.underlyingPage.keyboard.up('Control');
308317
await backspace();
309318
}
319+
debugPage('clearInput end');
310320
}
311321

312322
private everMoved = false;
@@ -371,6 +381,7 @@ export class Page<
371381
}
372382

373383
async navigate(url: string): Promise<void> {
384+
debugPage(`navigate to ${url}`);
374385
if (this.pageType === 'puppeteer') {
375386
await (this.underlyingPage as PuppeteerPage).goto(url);
376387
} else if (this.pageType === 'playwright') {

0 commit comments

Comments
 (0)