@letsscrapedata/controller 0.0.53 → 0.0.55
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.cjs +171 -0
- package/dist/index.d.cts +71 -2
- package/dist/index.d.ts +71 -2
- package/dist/index.js +171 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -124,6 +124,9 @@ var PlaywrightElement = class _PlaywrightElement {
|
|
|
124
124
|
const names = await this.#locator.evaluate((node) => node.getAttributeNames());
|
|
125
125
|
return names;
|
|
126
126
|
}
|
|
127
|
+
async boundingBox() {
|
|
128
|
+
return await this.#locator.boundingBox();
|
|
129
|
+
}
|
|
127
130
|
async dataset() {
|
|
128
131
|
try {
|
|
129
132
|
const dataset = await this.#locator.evaluate((node) => node.dataset);
|
|
@@ -899,6 +902,41 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
899
902
|
const width = await this.pageWidth();
|
|
900
903
|
return await this.setViewportSize({ height, width });
|
|
901
904
|
}
|
|
905
|
+
async mouseClick(x, y, options) {
|
|
906
|
+
if (!this.#page) {
|
|
907
|
+
throw new Error("No valid page");
|
|
908
|
+
}
|
|
909
|
+
await this.#page.mouse.click(x, y, options);
|
|
910
|
+
return true;
|
|
911
|
+
}
|
|
912
|
+
async mouseDown() {
|
|
913
|
+
if (!this.#page) {
|
|
914
|
+
throw new Error("No valid page");
|
|
915
|
+
}
|
|
916
|
+
await this.#page.mouse.down();
|
|
917
|
+
return true;
|
|
918
|
+
}
|
|
919
|
+
async mouseMove(x, y) {
|
|
920
|
+
if (!this.#page) {
|
|
921
|
+
throw new Error("No valid page");
|
|
922
|
+
}
|
|
923
|
+
await this.#page.mouse.move(x, y);
|
|
924
|
+
return true;
|
|
925
|
+
}
|
|
926
|
+
async mouseUp() {
|
|
927
|
+
if (!this.#page) {
|
|
928
|
+
throw new Error("No valid page");
|
|
929
|
+
}
|
|
930
|
+
await this.#page.mouse.up();
|
|
931
|
+
return true;
|
|
932
|
+
}
|
|
933
|
+
async mouseWheel(deltaX = 0, deltaY = 0) {
|
|
934
|
+
if (!this.#page) {
|
|
935
|
+
throw new Error("No valid page");
|
|
936
|
+
}
|
|
937
|
+
await this.#page.mouse.wheel(deltaX, deltaY);
|
|
938
|
+
return true;
|
|
939
|
+
}
|
|
902
940
|
async pageHeight() {
|
|
903
941
|
if (!this.#page) {
|
|
904
942
|
throw new Error("No valid page");
|
|
@@ -931,6 +969,18 @@ var PlaywrightPage = class extends import_node_events.default {
|
|
|
931
969
|
const buffer = await this.#page.pdf(options);
|
|
932
970
|
return buffer;
|
|
933
971
|
}
|
|
972
|
+
async reload() {
|
|
973
|
+
if (!this.#page) {
|
|
974
|
+
throw new Error("No valid page");
|
|
975
|
+
}
|
|
976
|
+
try {
|
|
977
|
+
await this.#page.reload();
|
|
978
|
+
return true;
|
|
979
|
+
} catch (err) {
|
|
980
|
+
loginfo(err);
|
|
981
|
+
return false;
|
|
982
|
+
}
|
|
983
|
+
}
|
|
934
984
|
async screenshot(options) {
|
|
935
985
|
if (!this.#page) {
|
|
936
986
|
throw new Error("No valid page");
|
|
@@ -1875,6 +1925,9 @@ var PuppeteerElement = class _PuppeteerElement {
|
|
|
1875
1925
|
const names = await this.#frame.evaluate((ele) => ele.getAttributeNames(), this.#$ele);
|
|
1876
1926
|
return names;
|
|
1877
1927
|
}
|
|
1928
|
+
async boundingBox() {
|
|
1929
|
+
return await this.#$ele.boundingBox();
|
|
1930
|
+
}
|
|
1878
1931
|
async dataset() {
|
|
1879
1932
|
try {
|
|
1880
1933
|
const attributeNames = await this.attributeNames();
|
|
@@ -2619,6 +2672,41 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
2619
2672
|
const width = await this.pageWidth();
|
|
2620
2673
|
return await this.setViewportSize({ height, width });
|
|
2621
2674
|
}
|
|
2675
|
+
async mouseClick(x, y, options) {
|
|
2676
|
+
if (!this.#page) {
|
|
2677
|
+
throw new Error("No valid page");
|
|
2678
|
+
}
|
|
2679
|
+
await this.#page.mouse.click(x, y, options);
|
|
2680
|
+
return true;
|
|
2681
|
+
}
|
|
2682
|
+
async mouseDown() {
|
|
2683
|
+
if (!this.#page) {
|
|
2684
|
+
throw new Error("No valid page");
|
|
2685
|
+
}
|
|
2686
|
+
await this.#page.mouse.down();
|
|
2687
|
+
return true;
|
|
2688
|
+
}
|
|
2689
|
+
async mouseMove(x, y) {
|
|
2690
|
+
if (!this.#page) {
|
|
2691
|
+
throw new Error("No valid page");
|
|
2692
|
+
}
|
|
2693
|
+
await this.#page.mouse.move(x, y);
|
|
2694
|
+
return true;
|
|
2695
|
+
}
|
|
2696
|
+
async mouseUp() {
|
|
2697
|
+
if (!this.#page) {
|
|
2698
|
+
throw new Error("No valid page");
|
|
2699
|
+
}
|
|
2700
|
+
await this.#page.mouse.up();
|
|
2701
|
+
return true;
|
|
2702
|
+
}
|
|
2703
|
+
async mouseWheel(deltaX = 0, deltaY = 0) {
|
|
2704
|
+
if (!this.#page) {
|
|
2705
|
+
throw new Error("No valid page");
|
|
2706
|
+
}
|
|
2707
|
+
await this.#page.mouse.wheel({ deltaX, deltaY });
|
|
2708
|
+
return true;
|
|
2709
|
+
}
|
|
2622
2710
|
async pageHeight() {
|
|
2623
2711
|
if (!this.#page) {
|
|
2624
2712
|
throw new Error("No valid page");
|
|
@@ -2651,6 +2739,18 @@ var PuppeteerPage = class extends import_node_events4.default {
|
|
|
2651
2739
|
const buffer = await this.#page.pdf(options);
|
|
2652
2740
|
return buffer;
|
|
2653
2741
|
}
|
|
2742
|
+
async reload() {
|
|
2743
|
+
if (!this.#page) {
|
|
2744
|
+
throw new Error("No valid page");
|
|
2745
|
+
}
|
|
2746
|
+
try {
|
|
2747
|
+
await this.#page.reload();
|
|
2748
|
+
return true;
|
|
2749
|
+
} catch (err) {
|
|
2750
|
+
loginfo(err);
|
|
2751
|
+
return false;
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2654
2754
|
async screenshot(options) {
|
|
2655
2755
|
if (!this.#page) {
|
|
2656
2756
|
throw new Error("No valid page");
|
|
@@ -3632,6 +3732,9 @@ var CheerioElement = class _CheerioElement {
|
|
|
3632
3732
|
const text = this.#node.text();
|
|
3633
3733
|
return text ? text : "";
|
|
3634
3734
|
}
|
|
3735
|
+
boundingBox() {
|
|
3736
|
+
throw new Error("Not supported in CheerioElement.");
|
|
3737
|
+
}
|
|
3635
3738
|
async click() {
|
|
3636
3739
|
throw new Error("Not supported in CheerioElement.");
|
|
3637
3740
|
}
|
|
@@ -3801,6 +3904,21 @@ var CheerioPage = class extends import_node_events7.default {
|
|
|
3801
3904
|
async maximizeViewport() {
|
|
3802
3905
|
throw new Error("Not supported in CheerioPage.");
|
|
3803
3906
|
}
|
|
3907
|
+
async mouseClick() {
|
|
3908
|
+
throw new Error("Not supported in CheerioPage.");
|
|
3909
|
+
}
|
|
3910
|
+
async mouseDown() {
|
|
3911
|
+
throw new Error("Not supported in CheerioPage.");
|
|
3912
|
+
}
|
|
3913
|
+
async mouseMove() {
|
|
3914
|
+
throw new Error("Not supported in CheerioPage.");
|
|
3915
|
+
}
|
|
3916
|
+
async mouseUp() {
|
|
3917
|
+
throw new Error("Not supported in CheerioPage.");
|
|
3918
|
+
}
|
|
3919
|
+
async mouseWheel() {
|
|
3920
|
+
throw new Error("Not supported in CheerioPage.");
|
|
3921
|
+
}
|
|
3804
3922
|
async pageHeight() {
|
|
3805
3923
|
throw new Error("Not supported in CheerioPage.");
|
|
3806
3924
|
}
|
|
@@ -3813,6 +3931,9 @@ var CheerioPage = class extends import_node_events7.default {
|
|
|
3813
3931
|
async pdf() {
|
|
3814
3932
|
throw new Error("Not supported in CheerioPage.");
|
|
3815
3933
|
}
|
|
3934
|
+
async reload() {
|
|
3935
|
+
throw new Error("Not supported in CheerioPage.");
|
|
3936
|
+
}
|
|
3816
3937
|
async screenshot() {
|
|
3817
3938
|
throw new Error("Not supported in CheerioPage.");
|
|
3818
3939
|
}
|
|
@@ -3919,6 +4040,9 @@ var PatchrightElement = class _PatchrightElement {
|
|
|
3919
4040
|
const names = await this.#locator.evaluate((node) => node.getAttributeNames());
|
|
3920
4041
|
return names;
|
|
3921
4042
|
}
|
|
4043
|
+
async boundingBox() {
|
|
4044
|
+
return await this.#locator.boundingBox();
|
|
4045
|
+
}
|
|
3922
4046
|
async dataset() {
|
|
3923
4047
|
try {
|
|
3924
4048
|
const dataset = await this.#locator.evaluate((node) => node.dataset);
|
|
@@ -4694,6 +4818,41 @@ var PatchrightPage = class extends import_node_events8.default {
|
|
|
4694
4818
|
const width = await this.pageWidth();
|
|
4695
4819
|
return await this.setViewportSize({ height, width });
|
|
4696
4820
|
}
|
|
4821
|
+
async mouseClick(x, y, options) {
|
|
4822
|
+
if (!this.#page) {
|
|
4823
|
+
throw new Error("No valid page");
|
|
4824
|
+
}
|
|
4825
|
+
await this.#page.mouse.click(x, y, options);
|
|
4826
|
+
return true;
|
|
4827
|
+
}
|
|
4828
|
+
async mouseDown() {
|
|
4829
|
+
if (!this.#page) {
|
|
4830
|
+
throw new Error("No valid page");
|
|
4831
|
+
}
|
|
4832
|
+
await this.#page.mouse.down();
|
|
4833
|
+
return true;
|
|
4834
|
+
}
|
|
4835
|
+
async mouseMove(x, y) {
|
|
4836
|
+
if (!this.#page) {
|
|
4837
|
+
throw new Error("No valid page");
|
|
4838
|
+
}
|
|
4839
|
+
await this.#page.mouse.move(x, y);
|
|
4840
|
+
return true;
|
|
4841
|
+
}
|
|
4842
|
+
async mouseUp() {
|
|
4843
|
+
if (!this.#page) {
|
|
4844
|
+
throw new Error("No valid page");
|
|
4845
|
+
}
|
|
4846
|
+
await this.#page.mouse.up();
|
|
4847
|
+
return true;
|
|
4848
|
+
}
|
|
4849
|
+
async mouseWheel(deltaX = 0, deltaY = 0) {
|
|
4850
|
+
if (!this.#page) {
|
|
4851
|
+
throw new Error("No valid page");
|
|
4852
|
+
}
|
|
4853
|
+
await this.#page.mouse.wheel(deltaX, deltaY);
|
|
4854
|
+
return true;
|
|
4855
|
+
}
|
|
4697
4856
|
async pageHeight() {
|
|
4698
4857
|
if (!this.#page) {
|
|
4699
4858
|
throw new Error("No valid page");
|
|
@@ -4726,6 +4885,18 @@ var PatchrightPage = class extends import_node_events8.default {
|
|
|
4726
4885
|
const buffer = await this.#page.pdf(options);
|
|
4727
4886
|
return buffer;
|
|
4728
4887
|
}
|
|
4888
|
+
async reload() {
|
|
4889
|
+
if (!this.#page) {
|
|
4890
|
+
throw new Error("No valid page");
|
|
4891
|
+
}
|
|
4892
|
+
try {
|
|
4893
|
+
await this.#page.reload();
|
|
4894
|
+
return true;
|
|
4895
|
+
} catch (err) {
|
|
4896
|
+
loginfo(err);
|
|
4897
|
+
return false;
|
|
4898
|
+
}
|
|
4899
|
+
}
|
|
4729
4900
|
async screenshot(options) {
|
|
4730
4901
|
if (!this.#page) {
|
|
4731
4902
|
throw new Error("No valid page");
|
package/dist/index.d.cts
CHANGED
|
@@ -372,6 +372,24 @@ interface MouseClickOptions {
|
|
|
372
372
|
*/
|
|
373
373
|
clickType?: MouseClickType;
|
|
374
374
|
}
|
|
375
|
+
interface PageMouseClickOptions {
|
|
376
|
+
/**
|
|
377
|
+
* Which button will be pressed.
|
|
378
|
+
* @default left
|
|
379
|
+
*/
|
|
380
|
+
button?: "left" | "right" | "middle";
|
|
381
|
+
/**
|
|
382
|
+
* Number of clicks to perform.
|
|
383
|
+
* * puppeteer: count (clickCount deprecated)
|
|
384
|
+
* @default 1
|
|
385
|
+
*/
|
|
386
|
+
clickCount?: 1 | 2 | 3;
|
|
387
|
+
/**
|
|
388
|
+
* Time to wait between mousedown and mouseup in milliseconds.
|
|
389
|
+
* @default 0
|
|
390
|
+
*/
|
|
391
|
+
delay?: number;
|
|
392
|
+
}
|
|
375
393
|
interface SelectOptions {
|
|
376
394
|
/**
|
|
377
395
|
* Which attribute of select option to match
|
|
@@ -455,6 +473,15 @@ interface LsdElement {
|
|
|
455
473
|
* @returns the attribute names of the element
|
|
456
474
|
*/
|
|
457
475
|
attributeNames(): Promise<string[]>;
|
|
476
|
+
/**
|
|
477
|
+
* This method returns the bounding box of the element (relative to the main frame), or null if the element is not part of the layout (example: display: none).
|
|
478
|
+
*/
|
|
479
|
+
boundingBox(): Promise<{
|
|
480
|
+
x: number;
|
|
481
|
+
y: number;
|
|
482
|
+
width: number;
|
|
483
|
+
height: number;
|
|
484
|
+
} | null>;
|
|
458
485
|
dataset(): Promise<Record<string, string>>;
|
|
459
486
|
/**
|
|
460
487
|
* In order to be compatible with various browser controllers, if you need to use this function, please follow the following conventions:
|
|
@@ -853,7 +880,7 @@ interface ScreenshotOptions {
|
|
|
853
880
|
*/
|
|
854
881
|
path?: string;
|
|
855
882
|
/**
|
|
856
|
-
* @defaultValue `'png'
|
|
883
|
+
* @defaultValue `'png'
|
|
857
884
|
*/
|
|
858
885
|
type?: 'png' | 'jpeg';
|
|
859
886
|
}
|
|
@@ -991,10 +1018,16 @@ interface LsdPage extends EventEmitter {
|
|
|
991
1018
|
localStroage(): Promise<LocalStorageOrigin[]>;
|
|
992
1019
|
mainFrame(): AllFrame;
|
|
993
1020
|
maximizeViewport(): Promise<boolean>;
|
|
1021
|
+
mouseClick(x: number, y: number, options?: PageMouseClickOptions): Promise<boolean>;
|
|
1022
|
+
mouseDown(): Promise<boolean>;
|
|
1023
|
+
mouseMove(x: number, y: number): Promise<boolean>;
|
|
1024
|
+
mouseUp(): Promise<boolean>;
|
|
1025
|
+
mouseWheel(deltaX?: number, delterY?: number): Promise<boolean>;
|
|
994
1026
|
pageHeight(): Promise<number>;
|
|
995
1027
|
pageInfo(): PageInfo;
|
|
996
1028
|
pageWidth(): Promise<number>;
|
|
997
1029
|
pdf(options?: PDFOptions): Promise<Buffer>;
|
|
1030
|
+
reload(): Promise<boolean>;
|
|
998
1031
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
999
1032
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
1000
1033
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
@@ -1284,10 +1317,16 @@ declare class PlaywrightPage extends EventEmitter implements LsdPage {
|
|
|
1284
1317
|
load(): boolean;
|
|
1285
1318
|
mainFrame(): AllFrame;
|
|
1286
1319
|
maximizeViewport(): Promise<boolean>;
|
|
1320
|
+
mouseClick(x: number, y: number, options?: PageMouseClickOptions): Promise<boolean>;
|
|
1321
|
+
mouseDown(): Promise<boolean>;
|
|
1322
|
+
mouseMove(x: number, y: number): Promise<boolean>;
|
|
1323
|
+
mouseUp(): Promise<boolean>;
|
|
1324
|
+
mouseWheel(deltaX?: number, deltaY?: number): Promise<boolean>;
|
|
1287
1325
|
pageHeight(): Promise<number>;
|
|
1288
1326
|
pageInfo(): PageInfo;
|
|
1289
1327
|
pageWidth(): Promise<number>;
|
|
1290
1328
|
pdf(options?: PDFOptions | undefined): Promise<Buffer>;
|
|
1329
|
+
reload(): Promise<boolean>;
|
|
1291
1330
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
1292
1331
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
1293
1332
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
@@ -1318,6 +1357,12 @@ declare class PlaywrightElement implements LsdElement {
|
|
|
1318
1357
|
constructor(locator: Locator, frame: Frame | FrameLocator);
|
|
1319
1358
|
attribute(attributeName: string): Promise<string>;
|
|
1320
1359
|
attributeNames(): Promise<string[]>;
|
|
1360
|
+
boundingBox(): Promise<{
|
|
1361
|
+
x: number;
|
|
1362
|
+
y: number;
|
|
1363
|
+
width: number;
|
|
1364
|
+
height: number;
|
|
1365
|
+
} | null>;
|
|
1321
1366
|
dataset(): Promise<Record<string, string>>;
|
|
1322
1367
|
evaluate(func: Function, args?: any[]): Promise<any>;
|
|
1323
1368
|
findElement(selectorOrXpath: string | string[], iframeOptions?: IframeOption[], absolute?: boolean): Promise<LsdElement | null>;
|
|
@@ -1420,10 +1465,16 @@ declare class PuppeteerPage extends EventEmitter implements LsdPage {
|
|
|
1420
1465
|
load(): boolean;
|
|
1421
1466
|
mainFrame(): AllFrame;
|
|
1422
1467
|
maximizeViewport(): Promise<boolean>;
|
|
1468
|
+
mouseClick(x: number, y: number, options?: PageMouseClickOptions): Promise<boolean>;
|
|
1469
|
+
mouseDown(): Promise<boolean>;
|
|
1470
|
+
mouseMove(x: number, y: number): Promise<boolean>;
|
|
1471
|
+
mouseUp(): Promise<boolean>;
|
|
1472
|
+
mouseWheel(deltaX?: number, deltaY?: number): Promise<boolean>;
|
|
1423
1473
|
pageHeight(): Promise<number>;
|
|
1424
1474
|
pageInfo(): PageInfo;
|
|
1425
1475
|
pageWidth(): Promise<number>;
|
|
1426
1476
|
pdf(options?: PDFOptions | undefined): Promise<Buffer>;
|
|
1477
|
+
reload(): Promise<boolean>;
|
|
1427
1478
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
1428
1479
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
1429
1480
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
@@ -1454,6 +1505,12 @@ declare class PuppeteerElement implements LsdElement {
|
|
|
1454
1505
|
constructor($ele: ElementHandle, frame: Frame$1);
|
|
1455
1506
|
attribute(attributeName: string): Promise<string>;
|
|
1456
1507
|
attributeNames(): Promise<string[]>;
|
|
1508
|
+
boundingBox(): Promise<{
|
|
1509
|
+
x: number;
|
|
1510
|
+
y: number;
|
|
1511
|
+
width: number;
|
|
1512
|
+
height: number;
|
|
1513
|
+
} | null>;
|
|
1457
1514
|
dataset(): Promise<Record<string, string>>;
|
|
1458
1515
|
evaluate(func: Function, args?: any[]): Promise<any>;
|
|
1459
1516
|
findElement(selectorOrXpath: string | string[], iframeOptions?: IframeOption[], absolute?: boolean): Promise<LsdElement | null>;
|
|
@@ -1513,10 +1570,16 @@ declare class CheerioPage extends EventEmitter implements LsdPage {
|
|
|
1513
1570
|
localStroage(): Promise<LocalStorageOrigin[]>;
|
|
1514
1571
|
mainFrame(): AllFrame;
|
|
1515
1572
|
maximizeViewport(): Promise<boolean>;
|
|
1573
|
+
mouseClick(): Promise<boolean>;
|
|
1574
|
+
mouseDown(): Promise<boolean>;
|
|
1575
|
+
mouseMove(): Promise<boolean>;
|
|
1576
|
+
mouseUp(): Promise<boolean>;
|
|
1577
|
+
mouseWheel(): Promise<boolean>;
|
|
1516
1578
|
pageHeight(): Promise<number>;
|
|
1517
1579
|
pageInfo(): PageInfo;
|
|
1518
1580
|
pageWidth(): Promise<number>;
|
|
1519
1581
|
pdf(): Promise<Buffer>;
|
|
1582
|
+
reload(): Promise<boolean>;
|
|
1520
1583
|
screenshot(): Promise<Buffer>;
|
|
1521
1584
|
scrollBy(): Promise<boolean>;
|
|
1522
1585
|
scrollTo(): Promise<boolean>;
|
|
@@ -1555,6 +1618,12 @@ declare class CheerioElement implements LsdElement {
|
|
|
1555
1618
|
innerText(): Promise<string>;
|
|
1556
1619
|
outerHtml(): Promise<string>;
|
|
1557
1620
|
textContent(): Promise<string>;
|
|
1621
|
+
boundingBox(): Promise<{
|
|
1622
|
+
x: number;
|
|
1623
|
+
y: number;
|
|
1624
|
+
width: number;
|
|
1625
|
+
height: number;
|
|
1626
|
+
} | null>;
|
|
1558
1627
|
click(): Promise<boolean>;
|
|
1559
1628
|
focus(): Promise<boolean>;
|
|
1560
1629
|
hover(): Promise<boolean>;
|
|
@@ -1577,4 +1646,4 @@ declare class LsdBrowserController implements LsdBrowserController$1 {
|
|
|
1577
1646
|
}
|
|
1578
1647
|
declare const controller: LsdBrowserController;
|
|
1579
1648
|
|
|
1580
|
-
export { type AllApiRequestContext, type AllBrowser, type AllBrowserContext, type AllElement, type AllElementHandle, type AllFrame, type AllPage, type AllResponse, type BrowserContextCreationMethod, type BrowserContextRequirements, type BrowserContextStatus, type BrowserControllerType, type BrowserCreationMethod, type BrowserLaunchMethod, type BrowserStateData, CheerioElement, type CheerioNode, CheerioPage, type ClientCertificate, type CookieItem, type FrameAddScriptTagOptions, type GotoOptions, type IframeOption, type InputOptions, type KeyInput, type KeyPressOptions, type LocalStorageItem, type LocalStorageOrigin, type LowerCasePaperFormat, type LsdApiContext, type LsdApiContextOptions, type LsdApiResponse, type LsdBrowser, type LsdBrowserContext, type LsdBrowserContextOptions, type LsdBrowserController$1 as LsdBrowserController, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdFetchOptions, type LsdLaunchOptions, type LsdPage, type MouseClickOptions, type MouseClickType, type NavigationWaitUntil, type PDFMargin, type PDFOptions, type PageEvent, type PageExtInPatchright, type PageExtInPlaywright, type PageExtInPuppeteer, type PageInfo, type PageOpenType, type PageStatus, type PaperFormat, type PatchrightBrowserTypes, PlaywrightBrowser, PlaywrightBrowserContext, type PlaywrightBrowserTypes, PlaywrightElement, PlaywrightPage, type ProxyInController, PuppeteerBrowser, PuppeteerBrowserContext, PuppeteerElement, PuppeteerPage, type RequestInterceptionAction, type RequestInterceptionOption, type RequestMatch, type RequestMethod, type RequestResourceType, type ResponseHandler, type ResponseHandlerOptions, type ResponseInterceptionItem, type ResponseInterceptionOption, type ResponseMatch, type ResponsePageData, type ScreenshotOptions, type SelectOptions, type UpdatablePageInfo, type ViewportSize, type WaitElementOptions, type WaitElementState, type WaitNavigationOptions, controller, setControllerLogFun };
|
|
1649
|
+
export { type AllApiRequestContext, type AllBrowser, type AllBrowserContext, type AllElement, type AllElementHandle, type AllFrame, type AllPage, type AllResponse, type BrowserContextCreationMethod, type BrowserContextRequirements, type BrowserContextStatus, type BrowserControllerType, type BrowserCreationMethod, type BrowserLaunchMethod, type BrowserStateData, CheerioElement, type CheerioNode, CheerioPage, type ClientCertificate, type CookieItem, type FrameAddScriptTagOptions, type GotoOptions, type IframeOption, type InputOptions, type KeyInput, type KeyPressOptions, type LocalStorageItem, type LocalStorageOrigin, type LowerCasePaperFormat, type LsdApiContext, type LsdApiContextOptions, type LsdApiResponse, type LsdBrowser, type LsdBrowserContext, type LsdBrowserContextOptions, type LsdBrowserController$1 as LsdBrowserController, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdFetchOptions, type LsdLaunchOptions, type LsdPage, type MouseClickOptions, type MouseClickType, type NavigationWaitUntil, type PDFMargin, type PDFOptions, type PageEvent, type PageExtInPatchright, type PageExtInPlaywright, type PageExtInPuppeteer, type PageInfo, type PageMouseClickOptions, type PageOpenType, type PageStatus, type PaperFormat, type PatchrightBrowserTypes, PlaywrightBrowser, PlaywrightBrowserContext, type PlaywrightBrowserTypes, PlaywrightElement, PlaywrightPage, type ProxyInController, PuppeteerBrowser, PuppeteerBrowserContext, PuppeteerElement, PuppeteerPage, type RequestInterceptionAction, type RequestInterceptionOption, type RequestMatch, type RequestMethod, type RequestResourceType, type ResponseHandler, type ResponseHandlerOptions, type ResponseInterceptionItem, type ResponseInterceptionOption, type ResponseMatch, type ResponsePageData, type ScreenshotOptions, type SelectOptions, type UpdatablePageInfo, type ViewportSize, type WaitElementOptions, type WaitElementState, type WaitNavigationOptions, controller, setControllerLogFun };
|
package/dist/index.d.ts
CHANGED
|
@@ -372,6 +372,24 @@ interface MouseClickOptions {
|
|
|
372
372
|
*/
|
|
373
373
|
clickType?: MouseClickType;
|
|
374
374
|
}
|
|
375
|
+
interface PageMouseClickOptions {
|
|
376
|
+
/**
|
|
377
|
+
* Which button will be pressed.
|
|
378
|
+
* @default left
|
|
379
|
+
*/
|
|
380
|
+
button?: "left" | "right" | "middle";
|
|
381
|
+
/**
|
|
382
|
+
* Number of clicks to perform.
|
|
383
|
+
* * puppeteer: count (clickCount deprecated)
|
|
384
|
+
* @default 1
|
|
385
|
+
*/
|
|
386
|
+
clickCount?: 1 | 2 | 3;
|
|
387
|
+
/**
|
|
388
|
+
* Time to wait between mousedown and mouseup in milliseconds.
|
|
389
|
+
* @default 0
|
|
390
|
+
*/
|
|
391
|
+
delay?: number;
|
|
392
|
+
}
|
|
375
393
|
interface SelectOptions {
|
|
376
394
|
/**
|
|
377
395
|
* Which attribute of select option to match
|
|
@@ -455,6 +473,15 @@ interface LsdElement {
|
|
|
455
473
|
* @returns the attribute names of the element
|
|
456
474
|
*/
|
|
457
475
|
attributeNames(): Promise<string[]>;
|
|
476
|
+
/**
|
|
477
|
+
* This method returns the bounding box of the element (relative to the main frame), or null if the element is not part of the layout (example: display: none).
|
|
478
|
+
*/
|
|
479
|
+
boundingBox(): Promise<{
|
|
480
|
+
x: number;
|
|
481
|
+
y: number;
|
|
482
|
+
width: number;
|
|
483
|
+
height: number;
|
|
484
|
+
} | null>;
|
|
458
485
|
dataset(): Promise<Record<string, string>>;
|
|
459
486
|
/**
|
|
460
487
|
* In order to be compatible with various browser controllers, if you need to use this function, please follow the following conventions:
|
|
@@ -853,7 +880,7 @@ interface ScreenshotOptions {
|
|
|
853
880
|
*/
|
|
854
881
|
path?: string;
|
|
855
882
|
/**
|
|
856
|
-
* @defaultValue `'png'
|
|
883
|
+
* @defaultValue `'png'
|
|
857
884
|
*/
|
|
858
885
|
type?: 'png' | 'jpeg';
|
|
859
886
|
}
|
|
@@ -991,10 +1018,16 @@ interface LsdPage extends EventEmitter {
|
|
|
991
1018
|
localStroage(): Promise<LocalStorageOrigin[]>;
|
|
992
1019
|
mainFrame(): AllFrame;
|
|
993
1020
|
maximizeViewport(): Promise<boolean>;
|
|
1021
|
+
mouseClick(x: number, y: number, options?: PageMouseClickOptions): Promise<boolean>;
|
|
1022
|
+
mouseDown(): Promise<boolean>;
|
|
1023
|
+
mouseMove(x: number, y: number): Promise<boolean>;
|
|
1024
|
+
mouseUp(): Promise<boolean>;
|
|
1025
|
+
mouseWheel(deltaX?: number, delterY?: number): Promise<boolean>;
|
|
994
1026
|
pageHeight(): Promise<number>;
|
|
995
1027
|
pageInfo(): PageInfo;
|
|
996
1028
|
pageWidth(): Promise<number>;
|
|
997
1029
|
pdf(options?: PDFOptions): Promise<Buffer>;
|
|
1030
|
+
reload(): Promise<boolean>;
|
|
998
1031
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
999
1032
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
1000
1033
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
@@ -1284,10 +1317,16 @@ declare class PlaywrightPage extends EventEmitter implements LsdPage {
|
|
|
1284
1317
|
load(): boolean;
|
|
1285
1318
|
mainFrame(): AllFrame;
|
|
1286
1319
|
maximizeViewport(): Promise<boolean>;
|
|
1320
|
+
mouseClick(x: number, y: number, options?: PageMouseClickOptions): Promise<boolean>;
|
|
1321
|
+
mouseDown(): Promise<boolean>;
|
|
1322
|
+
mouseMove(x: number, y: number): Promise<boolean>;
|
|
1323
|
+
mouseUp(): Promise<boolean>;
|
|
1324
|
+
mouseWheel(deltaX?: number, deltaY?: number): Promise<boolean>;
|
|
1287
1325
|
pageHeight(): Promise<number>;
|
|
1288
1326
|
pageInfo(): PageInfo;
|
|
1289
1327
|
pageWidth(): Promise<number>;
|
|
1290
1328
|
pdf(options?: PDFOptions | undefined): Promise<Buffer>;
|
|
1329
|
+
reload(): Promise<boolean>;
|
|
1291
1330
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
1292
1331
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
1293
1332
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
@@ -1318,6 +1357,12 @@ declare class PlaywrightElement implements LsdElement {
|
|
|
1318
1357
|
constructor(locator: Locator, frame: Frame | FrameLocator);
|
|
1319
1358
|
attribute(attributeName: string): Promise<string>;
|
|
1320
1359
|
attributeNames(): Promise<string[]>;
|
|
1360
|
+
boundingBox(): Promise<{
|
|
1361
|
+
x: number;
|
|
1362
|
+
y: number;
|
|
1363
|
+
width: number;
|
|
1364
|
+
height: number;
|
|
1365
|
+
} | null>;
|
|
1321
1366
|
dataset(): Promise<Record<string, string>>;
|
|
1322
1367
|
evaluate(func: Function, args?: any[]): Promise<any>;
|
|
1323
1368
|
findElement(selectorOrXpath: string | string[], iframeOptions?: IframeOption[], absolute?: boolean): Promise<LsdElement | null>;
|
|
@@ -1420,10 +1465,16 @@ declare class PuppeteerPage extends EventEmitter implements LsdPage {
|
|
|
1420
1465
|
load(): boolean;
|
|
1421
1466
|
mainFrame(): AllFrame;
|
|
1422
1467
|
maximizeViewport(): Promise<boolean>;
|
|
1468
|
+
mouseClick(x: number, y: number, options?: PageMouseClickOptions): Promise<boolean>;
|
|
1469
|
+
mouseDown(): Promise<boolean>;
|
|
1470
|
+
mouseMove(x: number, y: number): Promise<boolean>;
|
|
1471
|
+
mouseUp(): Promise<boolean>;
|
|
1472
|
+
mouseWheel(deltaX?: number, deltaY?: number): Promise<boolean>;
|
|
1423
1473
|
pageHeight(): Promise<number>;
|
|
1424
1474
|
pageInfo(): PageInfo;
|
|
1425
1475
|
pageWidth(): Promise<number>;
|
|
1426
1476
|
pdf(options?: PDFOptions | undefined): Promise<Buffer>;
|
|
1477
|
+
reload(): Promise<boolean>;
|
|
1427
1478
|
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
1428
1479
|
scrollBy(x: number, y: number): Promise<boolean>;
|
|
1429
1480
|
scrollTo(x: number, y: number): Promise<boolean>;
|
|
@@ -1454,6 +1505,12 @@ declare class PuppeteerElement implements LsdElement {
|
|
|
1454
1505
|
constructor($ele: ElementHandle, frame: Frame$1);
|
|
1455
1506
|
attribute(attributeName: string): Promise<string>;
|
|
1456
1507
|
attributeNames(): Promise<string[]>;
|
|
1508
|
+
boundingBox(): Promise<{
|
|
1509
|
+
x: number;
|
|
1510
|
+
y: number;
|
|
1511
|
+
width: number;
|
|
1512
|
+
height: number;
|
|
1513
|
+
} | null>;
|
|
1457
1514
|
dataset(): Promise<Record<string, string>>;
|
|
1458
1515
|
evaluate(func: Function, args?: any[]): Promise<any>;
|
|
1459
1516
|
findElement(selectorOrXpath: string | string[], iframeOptions?: IframeOption[], absolute?: boolean): Promise<LsdElement | null>;
|
|
@@ -1513,10 +1570,16 @@ declare class CheerioPage extends EventEmitter implements LsdPage {
|
|
|
1513
1570
|
localStroage(): Promise<LocalStorageOrigin[]>;
|
|
1514
1571
|
mainFrame(): AllFrame;
|
|
1515
1572
|
maximizeViewport(): Promise<boolean>;
|
|
1573
|
+
mouseClick(): Promise<boolean>;
|
|
1574
|
+
mouseDown(): Promise<boolean>;
|
|
1575
|
+
mouseMove(): Promise<boolean>;
|
|
1576
|
+
mouseUp(): Promise<boolean>;
|
|
1577
|
+
mouseWheel(): Promise<boolean>;
|
|
1516
1578
|
pageHeight(): Promise<number>;
|
|
1517
1579
|
pageInfo(): PageInfo;
|
|
1518
1580
|
pageWidth(): Promise<number>;
|
|
1519
1581
|
pdf(): Promise<Buffer>;
|
|
1582
|
+
reload(): Promise<boolean>;
|
|
1520
1583
|
screenshot(): Promise<Buffer>;
|
|
1521
1584
|
scrollBy(): Promise<boolean>;
|
|
1522
1585
|
scrollTo(): Promise<boolean>;
|
|
@@ -1555,6 +1618,12 @@ declare class CheerioElement implements LsdElement {
|
|
|
1555
1618
|
innerText(): Promise<string>;
|
|
1556
1619
|
outerHtml(): Promise<string>;
|
|
1557
1620
|
textContent(): Promise<string>;
|
|
1621
|
+
boundingBox(): Promise<{
|
|
1622
|
+
x: number;
|
|
1623
|
+
y: number;
|
|
1624
|
+
width: number;
|
|
1625
|
+
height: number;
|
|
1626
|
+
} | null>;
|
|
1558
1627
|
click(): Promise<boolean>;
|
|
1559
1628
|
focus(): Promise<boolean>;
|
|
1560
1629
|
hover(): Promise<boolean>;
|
|
@@ -1577,4 +1646,4 @@ declare class LsdBrowserController implements LsdBrowserController$1 {
|
|
|
1577
1646
|
}
|
|
1578
1647
|
declare const controller: LsdBrowserController;
|
|
1579
1648
|
|
|
1580
|
-
export { type AllApiRequestContext, type AllBrowser, type AllBrowserContext, type AllElement, type AllElementHandle, type AllFrame, type AllPage, type AllResponse, type BrowserContextCreationMethod, type BrowserContextRequirements, type BrowserContextStatus, type BrowserControllerType, type BrowserCreationMethod, type BrowserLaunchMethod, type BrowserStateData, CheerioElement, type CheerioNode, CheerioPage, type ClientCertificate, type CookieItem, type FrameAddScriptTagOptions, type GotoOptions, type IframeOption, type InputOptions, type KeyInput, type KeyPressOptions, type LocalStorageItem, type LocalStorageOrigin, type LowerCasePaperFormat, type LsdApiContext, type LsdApiContextOptions, type LsdApiResponse, type LsdBrowser, type LsdBrowserContext, type LsdBrowserContextOptions, type LsdBrowserController$1 as LsdBrowserController, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdFetchOptions, type LsdLaunchOptions, type LsdPage, type MouseClickOptions, type MouseClickType, type NavigationWaitUntil, type PDFMargin, type PDFOptions, type PageEvent, type PageExtInPatchright, type PageExtInPlaywright, type PageExtInPuppeteer, type PageInfo, type PageOpenType, type PageStatus, type PaperFormat, type PatchrightBrowserTypes, PlaywrightBrowser, PlaywrightBrowserContext, type PlaywrightBrowserTypes, PlaywrightElement, PlaywrightPage, type ProxyInController, PuppeteerBrowser, PuppeteerBrowserContext, PuppeteerElement, PuppeteerPage, type RequestInterceptionAction, type RequestInterceptionOption, type RequestMatch, type RequestMethod, type RequestResourceType, type ResponseHandler, type ResponseHandlerOptions, type ResponseInterceptionItem, type ResponseInterceptionOption, type ResponseMatch, type ResponsePageData, type ScreenshotOptions, type SelectOptions, type UpdatablePageInfo, type ViewportSize, type WaitElementOptions, type WaitElementState, type WaitNavigationOptions, controller, setControllerLogFun };
|
|
1649
|
+
export { type AllApiRequestContext, type AllBrowser, type AllBrowserContext, type AllElement, type AllElementHandle, type AllFrame, type AllPage, type AllResponse, type BrowserContextCreationMethod, type BrowserContextRequirements, type BrowserContextStatus, type BrowserControllerType, type BrowserCreationMethod, type BrowserLaunchMethod, type BrowserStateData, CheerioElement, type CheerioNode, CheerioPage, type ClientCertificate, type CookieItem, type FrameAddScriptTagOptions, type GotoOptions, type IframeOption, type InputOptions, type KeyInput, type KeyPressOptions, type LocalStorageItem, type LocalStorageOrigin, type LowerCasePaperFormat, type LsdApiContext, type LsdApiContextOptions, type LsdApiResponse, type LsdBrowser, type LsdBrowserContext, type LsdBrowserContextOptions, type LsdBrowserController$1 as LsdBrowserController, type LsdBrowserType, type LsdConnectOptions, type LsdElement, type LsdFetchOptions, type LsdLaunchOptions, type LsdPage, type MouseClickOptions, type MouseClickType, type NavigationWaitUntil, type PDFMargin, type PDFOptions, type PageEvent, type PageExtInPatchright, type PageExtInPlaywright, type PageExtInPuppeteer, type PageInfo, type PageMouseClickOptions, type PageOpenType, type PageStatus, type PaperFormat, type PatchrightBrowserTypes, PlaywrightBrowser, PlaywrightBrowserContext, type PlaywrightBrowserTypes, PlaywrightElement, PlaywrightPage, type ProxyInController, PuppeteerBrowser, PuppeteerBrowserContext, PuppeteerElement, PuppeteerPage, type RequestInterceptionAction, type RequestInterceptionOption, type RequestMatch, type RequestMethod, type RequestResourceType, type ResponseHandler, type ResponseHandlerOptions, type ResponseInterceptionItem, type ResponseInterceptionOption, type ResponseMatch, type ResponsePageData, type ScreenshotOptions, type SelectOptions, type UpdatablePageInfo, type ViewportSize, type WaitElementOptions, type WaitElementState, type WaitNavigationOptions, controller, setControllerLogFun };
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,9 @@ var PlaywrightElement = class _PlaywrightElement {
|
|
|
77
77
|
const names = await this.#locator.evaluate((node) => node.getAttributeNames());
|
|
78
78
|
return names;
|
|
79
79
|
}
|
|
80
|
+
async boundingBox() {
|
|
81
|
+
return await this.#locator.boundingBox();
|
|
82
|
+
}
|
|
80
83
|
async dataset() {
|
|
81
84
|
try {
|
|
82
85
|
const dataset = await this.#locator.evaluate((node) => node.dataset);
|
|
@@ -852,6 +855,41 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
852
855
|
const width = await this.pageWidth();
|
|
853
856
|
return await this.setViewportSize({ height, width });
|
|
854
857
|
}
|
|
858
|
+
async mouseClick(x, y, options) {
|
|
859
|
+
if (!this.#page) {
|
|
860
|
+
throw new Error("No valid page");
|
|
861
|
+
}
|
|
862
|
+
await this.#page.mouse.click(x, y, options);
|
|
863
|
+
return true;
|
|
864
|
+
}
|
|
865
|
+
async mouseDown() {
|
|
866
|
+
if (!this.#page) {
|
|
867
|
+
throw new Error("No valid page");
|
|
868
|
+
}
|
|
869
|
+
await this.#page.mouse.down();
|
|
870
|
+
return true;
|
|
871
|
+
}
|
|
872
|
+
async mouseMove(x, y) {
|
|
873
|
+
if (!this.#page) {
|
|
874
|
+
throw new Error("No valid page");
|
|
875
|
+
}
|
|
876
|
+
await this.#page.mouse.move(x, y);
|
|
877
|
+
return true;
|
|
878
|
+
}
|
|
879
|
+
async mouseUp() {
|
|
880
|
+
if (!this.#page) {
|
|
881
|
+
throw new Error("No valid page");
|
|
882
|
+
}
|
|
883
|
+
await this.#page.mouse.up();
|
|
884
|
+
return true;
|
|
885
|
+
}
|
|
886
|
+
async mouseWheel(deltaX = 0, deltaY = 0) {
|
|
887
|
+
if (!this.#page) {
|
|
888
|
+
throw new Error("No valid page");
|
|
889
|
+
}
|
|
890
|
+
await this.#page.mouse.wheel(deltaX, deltaY);
|
|
891
|
+
return true;
|
|
892
|
+
}
|
|
855
893
|
async pageHeight() {
|
|
856
894
|
if (!this.#page) {
|
|
857
895
|
throw new Error("No valid page");
|
|
@@ -884,6 +922,18 @@ var PlaywrightPage = class extends EventEmitter {
|
|
|
884
922
|
const buffer = await this.#page.pdf(options);
|
|
885
923
|
return buffer;
|
|
886
924
|
}
|
|
925
|
+
async reload() {
|
|
926
|
+
if (!this.#page) {
|
|
927
|
+
throw new Error("No valid page");
|
|
928
|
+
}
|
|
929
|
+
try {
|
|
930
|
+
await this.#page.reload();
|
|
931
|
+
return true;
|
|
932
|
+
} catch (err) {
|
|
933
|
+
loginfo(err);
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
887
937
|
async screenshot(options) {
|
|
888
938
|
if (!this.#page) {
|
|
889
939
|
throw new Error("No valid page");
|
|
@@ -1828,6 +1878,9 @@ var PuppeteerElement = class _PuppeteerElement {
|
|
|
1828
1878
|
const names = await this.#frame.evaluate((ele) => ele.getAttributeNames(), this.#$ele);
|
|
1829
1879
|
return names;
|
|
1830
1880
|
}
|
|
1881
|
+
async boundingBox() {
|
|
1882
|
+
return await this.#$ele.boundingBox();
|
|
1883
|
+
}
|
|
1831
1884
|
async dataset() {
|
|
1832
1885
|
try {
|
|
1833
1886
|
const attributeNames = await this.attributeNames();
|
|
@@ -2572,6 +2625,41 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
2572
2625
|
const width = await this.pageWidth();
|
|
2573
2626
|
return await this.setViewportSize({ height, width });
|
|
2574
2627
|
}
|
|
2628
|
+
async mouseClick(x, y, options) {
|
|
2629
|
+
if (!this.#page) {
|
|
2630
|
+
throw new Error("No valid page");
|
|
2631
|
+
}
|
|
2632
|
+
await this.#page.mouse.click(x, y, options);
|
|
2633
|
+
return true;
|
|
2634
|
+
}
|
|
2635
|
+
async mouseDown() {
|
|
2636
|
+
if (!this.#page) {
|
|
2637
|
+
throw new Error("No valid page");
|
|
2638
|
+
}
|
|
2639
|
+
await this.#page.mouse.down();
|
|
2640
|
+
return true;
|
|
2641
|
+
}
|
|
2642
|
+
async mouseMove(x, y) {
|
|
2643
|
+
if (!this.#page) {
|
|
2644
|
+
throw new Error("No valid page");
|
|
2645
|
+
}
|
|
2646
|
+
await this.#page.mouse.move(x, y);
|
|
2647
|
+
return true;
|
|
2648
|
+
}
|
|
2649
|
+
async mouseUp() {
|
|
2650
|
+
if (!this.#page) {
|
|
2651
|
+
throw new Error("No valid page");
|
|
2652
|
+
}
|
|
2653
|
+
await this.#page.mouse.up();
|
|
2654
|
+
return true;
|
|
2655
|
+
}
|
|
2656
|
+
async mouseWheel(deltaX = 0, deltaY = 0) {
|
|
2657
|
+
if (!this.#page) {
|
|
2658
|
+
throw new Error("No valid page");
|
|
2659
|
+
}
|
|
2660
|
+
await this.#page.mouse.wheel({ deltaX, deltaY });
|
|
2661
|
+
return true;
|
|
2662
|
+
}
|
|
2575
2663
|
async pageHeight() {
|
|
2576
2664
|
if (!this.#page) {
|
|
2577
2665
|
throw new Error("No valid page");
|
|
@@ -2604,6 +2692,18 @@ var PuppeteerPage = class extends EventEmitter4 {
|
|
|
2604
2692
|
const buffer = await this.#page.pdf(options);
|
|
2605
2693
|
return buffer;
|
|
2606
2694
|
}
|
|
2695
|
+
async reload() {
|
|
2696
|
+
if (!this.#page) {
|
|
2697
|
+
throw new Error("No valid page");
|
|
2698
|
+
}
|
|
2699
|
+
try {
|
|
2700
|
+
await this.#page.reload();
|
|
2701
|
+
return true;
|
|
2702
|
+
} catch (err) {
|
|
2703
|
+
loginfo(err);
|
|
2704
|
+
return false;
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2607
2707
|
async screenshot(options) {
|
|
2608
2708
|
if (!this.#page) {
|
|
2609
2709
|
throw new Error("No valid page");
|
|
@@ -3585,6 +3685,9 @@ var CheerioElement = class _CheerioElement {
|
|
|
3585
3685
|
const text = this.#node.text();
|
|
3586
3686
|
return text ? text : "";
|
|
3587
3687
|
}
|
|
3688
|
+
boundingBox() {
|
|
3689
|
+
throw new Error("Not supported in CheerioElement.");
|
|
3690
|
+
}
|
|
3588
3691
|
async click() {
|
|
3589
3692
|
throw new Error("Not supported in CheerioElement.");
|
|
3590
3693
|
}
|
|
@@ -3754,6 +3857,21 @@ var CheerioPage = class extends EventEmitter7 {
|
|
|
3754
3857
|
async maximizeViewport() {
|
|
3755
3858
|
throw new Error("Not supported in CheerioPage.");
|
|
3756
3859
|
}
|
|
3860
|
+
async mouseClick() {
|
|
3861
|
+
throw new Error("Not supported in CheerioPage.");
|
|
3862
|
+
}
|
|
3863
|
+
async mouseDown() {
|
|
3864
|
+
throw new Error("Not supported in CheerioPage.");
|
|
3865
|
+
}
|
|
3866
|
+
async mouseMove() {
|
|
3867
|
+
throw new Error("Not supported in CheerioPage.");
|
|
3868
|
+
}
|
|
3869
|
+
async mouseUp() {
|
|
3870
|
+
throw new Error("Not supported in CheerioPage.");
|
|
3871
|
+
}
|
|
3872
|
+
async mouseWheel() {
|
|
3873
|
+
throw new Error("Not supported in CheerioPage.");
|
|
3874
|
+
}
|
|
3757
3875
|
async pageHeight() {
|
|
3758
3876
|
throw new Error("Not supported in CheerioPage.");
|
|
3759
3877
|
}
|
|
@@ -3766,6 +3884,9 @@ var CheerioPage = class extends EventEmitter7 {
|
|
|
3766
3884
|
async pdf() {
|
|
3767
3885
|
throw new Error("Not supported in CheerioPage.");
|
|
3768
3886
|
}
|
|
3887
|
+
async reload() {
|
|
3888
|
+
throw new Error("Not supported in CheerioPage.");
|
|
3889
|
+
}
|
|
3769
3890
|
async screenshot() {
|
|
3770
3891
|
throw new Error("Not supported in CheerioPage.");
|
|
3771
3892
|
}
|
|
@@ -3872,6 +3993,9 @@ var PatchrightElement = class _PatchrightElement {
|
|
|
3872
3993
|
const names = await this.#locator.evaluate((node) => node.getAttributeNames());
|
|
3873
3994
|
return names;
|
|
3874
3995
|
}
|
|
3996
|
+
async boundingBox() {
|
|
3997
|
+
return await this.#locator.boundingBox();
|
|
3998
|
+
}
|
|
3875
3999
|
async dataset() {
|
|
3876
4000
|
try {
|
|
3877
4001
|
const dataset = await this.#locator.evaluate((node) => node.dataset);
|
|
@@ -4647,6 +4771,41 @@ var PatchrightPage = class extends EventEmitter8 {
|
|
|
4647
4771
|
const width = await this.pageWidth();
|
|
4648
4772
|
return await this.setViewportSize({ height, width });
|
|
4649
4773
|
}
|
|
4774
|
+
async mouseClick(x, y, options) {
|
|
4775
|
+
if (!this.#page) {
|
|
4776
|
+
throw new Error("No valid page");
|
|
4777
|
+
}
|
|
4778
|
+
await this.#page.mouse.click(x, y, options);
|
|
4779
|
+
return true;
|
|
4780
|
+
}
|
|
4781
|
+
async mouseDown() {
|
|
4782
|
+
if (!this.#page) {
|
|
4783
|
+
throw new Error("No valid page");
|
|
4784
|
+
}
|
|
4785
|
+
await this.#page.mouse.down();
|
|
4786
|
+
return true;
|
|
4787
|
+
}
|
|
4788
|
+
async mouseMove(x, y) {
|
|
4789
|
+
if (!this.#page) {
|
|
4790
|
+
throw new Error("No valid page");
|
|
4791
|
+
}
|
|
4792
|
+
await this.#page.mouse.move(x, y);
|
|
4793
|
+
return true;
|
|
4794
|
+
}
|
|
4795
|
+
async mouseUp() {
|
|
4796
|
+
if (!this.#page) {
|
|
4797
|
+
throw new Error("No valid page");
|
|
4798
|
+
}
|
|
4799
|
+
await this.#page.mouse.up();
|
|
4800
|
+
return true;
|
|
4801
|
+
}
|
|
4802
|
+
async mouseWheel(deltaX = 0, deltaY = 0) {
|
|
4803
|
+
if (!this.#page) {
|
|
4804
|
+
throw new Error("No valid page");
|
|
4805
|
+
}
|
|
4806
|
+
await this.#page.mouse.wheel(deltaX, deltaY);
|
|
4807
|
+
return true;
|
|
4808
|
+
}
|
|
4650
4809
|
async pageHeight() {
|
|
4651
4810
|
if (!this.#page) {
|
|
4652
4811
|
throw new Error("No valid page");
|
|
@@ -4679,6 +4838,18 @@ var PatchrightPage = class extends EventEmitter8 {
|
|
|
4679
4838
|
const buffer = await this.#page.pdf(options);
|
|
4680
4839
|
return buffer;
|
|
4681
4840
|
}
|
|
4841
|
+
async reload() {
|
|
4842
|
+
if (!this.#page) {
|
|
4843
|
+
throw new Error("No valid page");
|
|
4844
|
+
}
|
|
4845
|
+
try {
|
|
4846
|
+
await this.#page.reload();
|
|
4847
|
+
return true;
|
|
4848
|
+
} catch (err) {
|
|
4849
|
+
loginfo(err);
|
|
4850
|
+
return false;
|
|
4851
|
+
}
|
|
4852
|
+
}
|
|
4682
4853
|
async screenshot(options) {
|
|
4683
4854
|
if (!this.#page) {
|
|
4684
4855
|
throw new Error("No valid page");
|
package/package.json
CHANGED