surfsky 0.0.4 → 0.0.5
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 +2 -2
- package/dist/index.js +15 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1097,8 +1097,6 @@ declare abstract class Actions {
|
|
|
1097
1097
|
click(selector: string, options?: ClickOptions): Promise<any>;
|
|
1098
1098
|
dblclick(selector: string, options?: DblclickOptions): Promise<any>;
|
|
1099
1099
|
hover(selector: string, options?: HoverOptions): Promise<any>;
|
|
1100
|
-
type(selector: string, text: string): Promise<any>;
|
|
1101
|
-
fill(selector: string, text: string): Promise<any>;
|
|
1102
1100
|
scroll(options?: ScrollOptions): Promise<any>;
|
|
1103
1101
|
scrollIntoView(selector: string, options?: {
|
|
1104
1102
|
behavior?: ScrollBehavior;
|
|
@@ -1368,6 +1366,8 @@ declare class Page extends Actions {
|
|
|
1368
1366
|
waitForFunction(expression: string | ((...args: any[]) => unknown), options?: EvaluateOptions & WaitOptions): Promise<any>;
|
|
1369
1367
|
innerText(selector: string): Promise<string | null>;
|
|
1370
1368
|
allInnerTexts(selector: string): Promise<string[]>;
|
|
1369
|
+
type(selector: string, text: string): Promise<any>;
|
|
1370
|
+
fill(selector: string, text: string): Promise<any>;
|
|
1371
1371
|
getAttribute(selector: string, name: string): Promise<string | null>;
|
|
1372
1372
|
count(selector: string): Promise<number>;
|
|
1373
1373
|
selectOption(selector: string, option: string | {
|
package/dist/index.js
CHANGED
|
@@ -85,14 +85,6 @@ var Actions = class {
|
|
|
85
85
|
...options
|
|
86
86
|
}));
|
|
87
87
|
}
|
|
88
|
-
async type(selector, text) {
|
|
89
|
-
await this.click(selector);
|
|
90
|
-
return this.keyboard.type(text);
|
|
91
|
-
}
|
|
92
|
-
async fill(selector, text) {
|
|
93
|
-
await this.click(selector, { clickCount: 3 });
|
|
94
|
-
return this.keyboard.type(text);
|
|
95
|
-
}
|
|
96
88
|
scroll(options = {}) {
|
|
97
89
|
return this.send("Human.scroll", cdpParams({ ...options }));
|
|
98
90
|
}
|
|
@@ -1323,6 +1315,20 @@ var Page = class extends Actions {
|
|
|
1323
1315
|
allInnerTexts(selector) {
|
|
1324
1316
|
return this.evaluate("s => Array.from(document.querySelectorAll(s), e => e.innerText)", { args: [selector] });
|
|
1325
1317
|
}
|
|
1318
|
+
async type(selector, text) {
|
|
1319
|
+
await this.click(selector);
|
|
1320
|
+
await this.#validateFocus(selector);
|
|
1321
|
+
return this.keyboard.type(text);
|
|
1322
|
+
}
|
|
1323
|
+
async fill(selector, text) {
|
|
1324
|
+
await this.click(selector, { clickCount: 3 });
|
|
1325
|
+
await this.#validateFocus(selector);
|
|
1326
|
+
if (text === "") return this.keyboard.press("Backspace");
|
|
1327
|
+
return this.keyboard.type(text);
|
|
1328
|
+
}
|
|
1329
|
+
async #validateFocus(selector) {
|
|
1330
|
+
if (!await this.evaluate("s => document.activeElement === document.querySelector(s)", { args: [selector] })) throw new Error(`'${selector}' did not take focus`);
|
|
1331
|
+
}
|
|
1326
1332
|
async getAttribute(selector, name) {
|
|
1327
1333
|
const nodeId = await this.#nodeId(selector);
|
|
1328
1334
|
if (nodeId === void 0) return null;
|
|
@@ -2618,7 +2624,7 @@ var Proxies = class {
|
|
|
2618
2624
|
};
|
|
2619
2625
|
//#endregion
|
|
2620
2626
|
//#region src/version.ts
|
|
2621
|
-
const VERSION = "0.0.
|
|
2627
|
+
const VERSION = "0.0.5";
|
|
2622
2628
|
//#endregion
|
|
2623
2629
|
//#region src/client.ts
|
|
2624
2630
|
function userAgent() {
|