pp-robot-module 0.2.14

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.
Files changed (84) hide show
  1. package/README.md +34 -0
  2. package/dist/MR/Ai.d.ts +8 -0
  3. package/dist/MR/Ai.js +24 -0
  4. package/dist/MR/Clipboard.d.ts +20 -0
  5. package/dist/MR/Clipboard.js +60 -0
  6. package/dist/MR/Csv.d.ts +20 -0
  7. package/dist/MR/Csv.js +56 -0
  8. package/dist/MR/Date.d.ts +60 -0
  9. package/dist/MR/Date.js +94 -0
  10. package/dist/MR/DbClient.d.ts +97 -0
  11. package/dist/MR/DbClient.js +269 -0
  12. package/dist/MR/Dialog.d.ts +0 -0
  13. package/dist/MR/Dialog.js +40 -0
  14. package/dist/MR/Excel.d.ts +110 -0
  15. package/dist/MR/Excel.js +316 -0
  16. package/dist/MR/File.d.ts +162 -0
  17. package/dist/MR/File.js +399 -0
  18. package/dist/MR/Hash.d.ts +12 -0
  19. package/dist/MR/Hash.js +21 -0
  20. package/dist/MR/Html.d.ts +38 -0
  21. package/dist/MR/Html.js +163 -0
  22. package/dist/MR/Http.d.ts +33 -0
  23. package/dist/MR/Http.js +121 -0
  24. package/dist/MR/Imap.d.ts +15 -0
  25. package/dist/MR/Imap.js +52 -0
  26. package/dist/MR/Ini.d.ts +31 -0
  27. package/dist/MR/Ini.js +55 -0
  28. package/dist/MR/Keyboard.d.ts +59 -0
  29. package/dist/MR/Keyboard.js +515 -0
  30. package/dist/MR/Log.d.ts +7 -0
  31. package/dist/MR/Log.js +52 -0
  32. package/dist/MR/Mouse.d.ts +51 -0
  33. package/dist/MR/Mouse.js +152 -0
  34. package/dist/MR/Net.d.ts +17 -0
  35. package/dist/MR/Net.js +74 -0
  36. package/dist/MR/Pdf.d.ts +113 -0
  37. package/dist/MR/Pdf.js +197 -0
  38. package/dist/MR/Process.d.ts +46 -0
  39. package/dist/MR/Process.js +106 -0
  40. package/dist/MR/QRcode.d.ts +13 -0
  41. package/dist/MR/QRcode.js +37 -0
  42. package/dist/MR/RedisClient.d.ts +40 -0
  43. package/dist/MR/RedisClient.js +183 -0
  44. package/dist/MR/Regex.d.ts +16 -0
  45. package/dist/MR/Regex.js +20 -0
  46. package/dist/MR/Robot.d.ts +19 -0
  47. package/dist/MR/Robot.js +31 -0
  48. package/dist/MR/Screen.d.ts +20 -0
  49. package/dist/MR/Screen.js +79 -0
  50. package/dist/MR/Smtp.d.ts +21 -0
  51. package/dist/MR/Smtp.js +83 -0
  52. package/dist/MR/String.d.ts +104 -0
  53. package/dist/MR/String.js +166 -0
  54. package/dist/MR/System.d.ts +31 -0
  55. package/dist/MR/System.js +201 -0
  56. package/dist/MR/Validator.d.ts +30 -0
  57. package/dist/MR/Validator.js +104 -0
  58. package/dist/MR/WebBrowser.d.ts +210 -0
  59. package/dist/MR/WebBrowser.js +484 -0
  60. package/dist/MR/WebBrowser2.d.ts +0 -0
  61. package/dist/MR/WebBrowser2.js +504 -0
  62. package/dist/MR/WebElement.d.ts +123 -0
  63. package/dist/MR/WebElement.js +172 -0
  64. package/dist/MR/WebKeyboard.d.ts +21 -0
  65. package/dist/MR/WebKeyboard.js +48 -0
  66. package/dist/MR/WebMouse.d.ts +46 -0
  67. package/dist/MR/WebMouse.js +79 -0
  68. package/dist/MR/Window.d.ts +8 -0
  69. package/dist/MR/Window.js +34 -0
  70. package/dist/MR/Word.d.ts +56 -0
  71. package/dist/MR/Word.js +220 -0
  72. package/dist/MR/Zip.d.ts +25 -0
  73. package/dist/MR/Zip.js +89 -0
  74. package/dist/bin/inputting-method.exe +0 -0
  75. package/dist/bin/keyboard-password.exe +0 -0
  76. package/dist/bin/lock-window.exe +0 -0
  77. package/dist/bin/printer-pdf.exe +0 -0
  78. package/dist/dotenv.d.ts +0 -0
  79. package/dist/dotenv.js +2 -0
  80. package/dist/index.d.ts +54 -0
  81. package/dist/index.js +63 -0
  82. package/dist/util.d.ts +17 -0
  83. package/dist/util.js +41 -0
  84. package/package.json +120 -0
@@ -0,0 +1,504 @@
1
+ // import {
2
+ // Builder,
3
+ // By,
4
+ // Capabilities,
5
+ // Condition,
6
+ // IWebDriverOptionsCookie,
7
+ // ThenableWebDriver,
8
+ // WebElement,
9
+ // until,
10
+ // Key,
11
+ // Alert,
12
+ // Locator
13
+ // } from "selenium-webdriver";
14
+ // import { Command } from "selenium-webdriver/lib/command";
15
+ // import * as fs from "fs";
16
+ // import util from "../util";
17
+ // import Logger from "./Log";
18
+ // import File from "./File";
19
+ // export namespace MR {
20
+ // export class WebBrowser {
21
+ // private static webBrowser: WebBrowser;
22
+ // public driver: ThenableWebDriver;
23
+ // private capabilities: Capabilities;
24
+ // /**
25
+ // * Creates a condition that will wait.
26
+ // */
27
+ // public Until = until;
28
+ // /**
29
+ // * Representations of pressable keys that aren't text. These are stored in
30
+ // * the Unicode PUA (Private Use Area) code points, 0xE000-0xF8FF. Refer to
31
+ // * http://www.google.com.au/search?&q=unicode+pua&btnG=Search
32
+ // */
33
+ // public Key = Key;
34
+ // /**
35
+ // * Describes a mechanism for locating an element on the page.
36
+ // */
37
+ // public By = By;
38
+ // private static headless: boolean =
39
+ // (process.env.WEB_BROWSER_HEADLESS || "true") === "true";
40
+ // private static mobile: boolean = process.env.WEB_BROWSER_MOBILE === "true";
41
+ // private static outDir: string = process.env.WORKSPACE_DIR || "./";
42
+ // private static userDataDir: string = `${WebBrowser.outDir}/user-data`;
43
+ // public static get instance(): WebBrowser {
44
+ // if (!this.webBrowser) {
45
+ // this.webBrowser = new WebBrowser();
46
+ // }
47
+ // return this.webBrowser;
48
+ // }
49
+ // private constructor() {
50
+ // // File.rimraf({ dirPath: WebBrowser.userDataDir });
51
+ // this.capabilities = Capabilities.chrome();
52
+ // const args = [
53
+ // "--no-sandbox",
54
+ // "--disable-gpu",
55
+ // "--window-size=1980,1200",
56
+ // "--enable-features=NetworkService,NetworkServiceInProcess", // refs: https://bugs.chromium.org/p/chromedriver/issues/detail?id=2897
57
+ // `--user-data-dir=${WebBrowser.userDataDir}`,
58
+ // "--disable-dev-shm-usage" // refs: https://stackoverflow.com/questions/50642308/webdriverexception-unknown-error-devtoolsactiveport-file-doesnt-exist-while-t
59
+ // ];
60
+ // if (WebBrowser.headless) {
61
+ // args.push("--headless");
62
+ // }
63
+ // const prefs = {
64
+ // "download.default_directory": WebBrowser.outDir,
65
+ // "download.prompt_for_download": false
66
+ // };
67
+ // let mobileEmulation = {};
68
+ // if (WebBrowser.mobile) {
69
+ // mobileEmulation = {
70
+ // deviceMetrics: { width: 360, height: 640, pixelRatio: 3.0 },
71
+ // userAgent:
72
+ // "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19"
73
+ // };
74
+ // }
75
+ // this.capabilities.set("goog:chromeOptions", {
76
+ // args,
77
+ // prefs,
78
+ // mobileEmulation
79
+ // });
80
+ // this.driver = new Builder().withCapabilities(this.capabilities).build();
81
+ // this.enableDownloadInHeadlessChrome();
82
+ // }
83
+ // /**
84
+ // * Navigate to the given URL.
85
+ // * @param url
86
+ // */
87
+ // public get(url: string): Promise<void> {
88
+ // Logger.debug("WebBrowser.get", { url });
89
+ // return this.driver.get(url);
90
+ // }
91
+ // /**
92
+ // * Quit the current session.
93
+ // * After calling quit, this instance will be invalidated and
94
+ // * may no longer be used to issue commands against the browser.
95
+ // */
96
+ // public quit(): Promise<void> {
97
+ // Logger.debug("WebBrowser.quit");
98
+ // return this.driver.quit();
99
+ // }
100
+ // /**
101
+ // * Wait for a condition to hold.
102
+ // * @param condition The condition to wait on, defined as a promise,
103
+ // * condition object, or a function to evaluate as a condition.
104
+ // * @param optTimeout How long to wait, in milliseconds, for the condition to be true.
105
+ // */
106
+ // public wait<T>(
107
+ // condition: Condition<T> | PromiseLike<T> | Function,
108
+ // optTimeout?: number
109
+ // ): Promise<T> {
110
+ // Logger.debug("WebBrowser.wait", { condition, optTimeout });
111
+ // return this.driver.wait(condition, optTimeout);
112
+ // }
113
+ // /**
114
+ // * Move the mouse to the center of the specified element.
115
+ // * @param element
116
+ // */
117
+ // public async mouseMove(
118
+ // element: Promise<WebElement> | WebElement
119
+ // ): Promise<void> {
120
+ // Logger.debug("WebBrowser.mouseMove");
121
+ // const actions = this.driver.actions({ bridge: true });
122
+ // const mouse = actions.mouse();
123
+ // actions.pause(mouse).move({ origin: await element });
124
+ // return actions.perform();
125
+ // }
126
+ // /**
127
+ // * Click on the specified element.
128
+ // * @param element
129
+ // */
130
+ // public async mouseClick(
131
+ // element: Promise<WebElement> | WebElement
132
+ // ): Promise<void> {
133
+ // Logger.debug("WebBrowser.mouseClick");
134
+ // const actions = this.driver.actions({ bridge: true });
135
+ // const mouse = actions.mouse();
136
+ // actions
137
+ // .pause(mouse)
138
+ // .move({ origin: await element })
139
+ // .press()
140
+ // .release();
141
+ // return actions.perform();
142
+ // }
143
+ // /**
144
+ // * Type a sequence on the specified element.
145
+ // * @param element
146
+ // * @param args The sequence of keys to type.
147
+ // */
148
+ // /* eslint-disable class-methods-use-this */
149
+ // public async sendKeys(
150
+ // element: Promise<WebElement> | WebElement,
151
+ // [args]: (string | number | Promise<string | number>)[]
152
+ // ): Promise<void> {
153
+ // Logger.debug("WebBrowser.sendKeys");
154
+ // return (await element).sendKeys(args);
155
+ // }
156
+ // /* eslint-enable class-methods-use-this */
157
+ // /**
158
+ // * Find an element on the page by a CSS selector.
159
+ // * @param selector
160
+ // */
161
+ // public findElement(selector: string): Promise<WebElement> {
162
+ // Logger.debug("WebBrowser.findElement", { selector });
163
+ // return this.driver.findElement(By.css(selector));
164
+ // }
165
+ // /**
166
+ // * Search for multiple elements on the page by a CSS selector.
167
+ // * @param selector
168
+ // */
169
+ // public findElements(selector: string): Promise<WebElement[]> {
170
+ // Logger.debug("WebBrowser.findElement", { selector });
171
+ // return this.driver.findElements(By.css(selector));
172
+ // }
173
+ // /**
174
+ // * Find an element on the page by the ID attribute.
175
+ // * @param id
176
+ // */
177
+ // public findElementById(id: string): Promise<WebElement> {
178
+ // Logger.debug("WebBrowser.findElementById", { id });
179
+ // return this.driver.findElement(By.id(id));
180
+ // }
181
+ // /**
182
+ // * Search for multiple elements on the page by the ID attribute.
183
+ // * @param id
184
+ // */
185
+ // public findElementsById(id: string): Promise<WebElement[]> {
186
+ // Logger.debug("WebBrowser.findElementById", { id });
187
+ // return this.driver.findElements(By.id(id));
188
+ // }
189
+ // /**
190
+ // * Find an element on the page that has a specific class name.
191
+ // * @param name
192
+ // */
193
+ // public findElementByClassName(name: string): Promise<WebElement> {
194
+ // Logger.debug("WebBrowser.findElementByClassName", { name });
195
+ // return this.driver.findElement(By.className(name));
196
+ // }
197
+ // /**
198
+ // * Search for multiple elements on the page that have a specific class name.
199
+ // * @param name
200
+ // */
201
+ // public findElementsByClassName(name: string): Promise<WebElement[]> {
202
+ // Logger.debug("WebBrowser.findElementByClassName", { name });
203
+ // return this.driver.findElements(By.className(name));
204
+ // }
205
+ // /**
206
+ // * Find an element on the page by a CSS selector.
207
+ // * @param selector
208
+ // */
209
+ // public findElementByCSSSelector(selector: string): Promise<WebElement> {
210
+ // Logger.debug("WebBrowser.findElementByCSSSelector", { selector });
211
+ // return this.driver.findElement(By.css(selector));
212
+ // }
213
+ // /**
214
+ // * Search for multiple elements on the page by a CSS selector.
215
+ // * @param selector
216
+ // */
217
+ // public findElementsByCSSSelector(selector: string): Promise<WebElement[]> {
218
+ // Logger.debug("WebBrowser.findElementByCSSSelector", { selector });
219
+ // return this.driver.findElements(By.css(selector));
220
+ // }
221
+ // /**
222
+ // * Find an element on the page by a XPath.
223
+ // * @param xpath
224
+ // */
225
+ // public findElementByXPath(xpath: string): Promise<WebElement> {
226
+ // Logger.debug("WebBrowser.findElementByXPath", { xpath });
227
+ // return this.driver.findElement(By.xpath(xpath));
228
+ // }
229
+ // /**
230
+ // * Search for multiple elements on the page by a XPath.
231
+ // * @param xpath
232
+ // */
233
+ // public findElementsByXPath(xpath: string): Promise<WebElement[]> {
234
+ // Logger.debug("WebBrowser.findElementByXPath", { xpath });
235
+ // return this.driver.findElements(By.xpath(xpath));
236
+ // }
237
+ // /**
238
+ // * Find a link element whose text matches the given string.
239
+ // * @param text
240
+ // */
241
+ // public findElementByLinkText(text: string): Promise<WebElement> {
242
+ // Logger.debug("WebBrowser.findElementByLinkText", { text });
243
+ // return this.driver.findElement(By.linkText(text));
244
+ // }
245
+ // /**
246
+ // * Test whether an element is found with the given locator.
247
+ // * @param locator
248
+ // */
249
+ // public async elementLocated(locator: Locator): Promise<boolean> {
250
+ // Logger.debug("WebBrowser.elementLocated", { locator });
251
+ // const elements = await this.driver.findElements(locator);
252
+ // return elements.length > 0;
253
+ // }
254
+ // /**
255
+ // * Take a screenshot.
256
+ // */
257
+ // public async takeScreenshot(): Promise<void> {
258
+ // Logger.debug("WebBrowser.takeScreenshot");
259
+ // const image = await this.driver.takeScreenshot();
260
+ // return fs.writeFile(
261
+ // `${WebBrowser.outDir}/${Math.round(new Date().getTime() / 1000)}.png`,
262
+ // image,
263
+ // "base64",
264
+ // (error): void => {
265
+ // if (error != null) {
266
+ // Logger.error(error);
267
+ // }
268
+ // }
269
+ // );
270
+ // }
271
+ // /**
272
+ // * Retrieve the URL of the current page.
273
+ // */
274
+ // public getCurrentUrl(): Promise<string> {
275
+ // Logger.debug("WebBrowser.getCurrentUrl");
276
+ // return this.driver.getCurrentUrl();
277
+ // }
278
+ // /**
279
+ // * Retrieve the cookie with the given name.
280
+ // * Returns null if there is no such cookie.
281
+ // * The cookie will be returned as a JSON object as described by the WebDriver wire protocol.
282
+ // * @param name
283
+ // */
284
+ // public getCookie(name: string): Promise<IWebDriverOptionsCookie> {
285
+ // Logger.debug("WebBrowser.getCookie", { name });
286
+ // return this.driver.manage().getCookie(name);
287
+ // }
288
+ // /**
289
+ // * Retrieve all cookies visible to the current page.
290
+ // * Each cookie will be returned as a JSON object as described by the WebDriver wire protocol.
291
+ // */
292
+ // public getCookies(): Promise<IWebDriverOptionsCookie[]> {
293
+ // Logger.debug("WebBrowser.getCookies");
294
+ // return this.driver.manage().getCookies();
295
+ // }
296
+ // /**
297
+ // * Scroll to the element
298
+ // */
299
+ // public async scrollTo(params: {
300
+ // selector?: string;
301
+ // xpath?: string;
302
+ // /** The selector of an element that is set CSS `overflow` property */
303
+ // containerSelector?: string;
304
+ // /** The XPath of an element that is set CSS `overflow` property */
305
+ // containerXpath?: string;
306
+ // }): Promise<void> {
307
+ // Logger.debug("WebBrowser.scrollTo", params);
308
+ // if (params.containerSelector || params.containerXpath) {
309
+ // await this.driver.executeScript(
310
+ // (
311
+ // selector: string,
312
+ // xpath: string,
313
+ // containerSelector: string,
314
+ // containerXpath: string
315
+ // ): void => {
316
+ // /* eslint-disable no-undef */
317
+ // const target = selector
318
+ // ? document.querySelector(selector)
319
+ // : (document
320
+ // .evaluate(xpath, document, null, XPathResult.ANY_TYPE, null)
321
+ // .iterateNext() as Element);
322
+ // const container = containerSelector
323
+ // ? document.querySelector(containerSelector)
324
+ // : (document
325
+ // .evaluate(
326
+ // containerXpath,
327
+ // document,
328
+ // null,
329
+ // XPathResult.ANY_TYPE,
330
+ // null
331
+ // )
332
+ // .iterateNext() as Element);
333
+ // const x =
334
+ // target.getBoundingClientRect().left -
335
+ // container.getBoundingClientRect().left -
336
+ // container.clientWidth / 2;
337
+ // const y =
338
+ // target.getBoundingClientRect().top -
339
+ // container.getBoundingClientRect().top -
340
+ // container.clientHeight / 2;
341
+ // container.scrollTo(x, y);
342
+ // /* eslint-enable no-undef */
343
+ // },
344
+ // params.selector,
345
+ // params.xpath,
346
+ // params.containerSelector,
347
+ // params.containerXpath
348
+ // );
349
+ // }
350
+ // await this.driver.executeScript(
351
+ // (selector: string, xpath: string): void => {
352
+ // /* eslint-disable no-undef */
353
+ // const target = selector
354
+ // ? document.querySelector(selector)
355
+ // : (document
356
+ // .evaluate(xpath, document, null, XPathResult.ANY_TYPE, null)
357
+ // .iterateNext() as Element);
358
+ // const x =
359
+ // target.getBoundingClientRect().left +
360
+ // window.pageXOffset -
361
+ // window.innerWidth / 2;
362
+ // const y =
363
+ // target.getBoundingClientRect().top +
364
+ // window.pageYOffset -
365
+ // window.innerHeight / 2;
366
+ // window.scrollTo(x, y);
367
+ // /* eslint-enable no-undef */
368
+ // },
369
+ // params.selector,
370
+ // params.xpath
371
+ // );
372
+ // }
373
+ // /**
374
+ // * Retrieve the current window handle.
375
+ // */
376
+ // public async getWindowHandle(): Promise<string> {
377
+ // Logger.debug("WebBrowser.getWindowHandle");
378
+ // return this.driver.getWindowHandle();
379
+ // }
380
+ // /**
381
+ // * Retrieve the current list of available window handles.
382
+ // */
383
+ // public async getAllWindowHandles(): Promise<string[]> {
384
+ // Logger.debug("WebBrowser.getAllWindowHandles");
385
+ // return this.driver.getAllWindowHandles();
386
+ // }
387
+ // /**
388
+ // * Switch the focus of all future commands to another window.
389
+ // */
390
+ // public async switchToWindow(windowHandle: string): Promise<void> {
391
+ // Logger.debug("WebBrowser.switchToWindow", windowHandle);
392
+ // await this.driver.switchTo().window(windowHandle);
393
+ // }
394
+ // /**
395
+ // * Switch the focus of all future commands to another frame.
396
+ // * @param {Promise<WebElement>|WebElement|null} frame
397
+ // * A WebElement reference, which correspond to a `frame` or `iframe` DOM element.
398
+ // * If not specified, selects the topmost frame on the page.
399
+ // */
400
+ // public async switchToFrame(
401
+ // frame?: Promise<WebElement> | WebElement
402
+ // ): Promise<void> {
403
+ // Logger.debug("WebBrowser.switchToFrame");
404
+ // await this.driver.switchTo().frame(frame ? await frame : null);
405
+ // }
406
+ // /**
407
+ // * Close a window.
408
+ // * If no window is specified, close the current window.
409
+ // */
410
+ // public async closeWindow(windowHandle?: string): Promise<void> {
411
+ // Logger.debug("WebBrowser.closeWindow", windowHandle);
412
+ // const currentWindow = await this.driver.getWindowHandle();
413
+ // if (windowHandle != null && windowHandle !== currentWindow) {
414
+ // await this.driver.switchTo().window(windowHandle);
415
+ // await this.driver.close();
416
+ // await this.driver.switchTo().window(currentWindow);
417
+ // } else {
418
+ // await this.driver.close();
419
+ // }
420
+ // }
421
+ // /**
422
+ // * Change focus to the active modal dialog,
423
+ // * such as those opened by `window.alert()`, `window.confirm()`, and `window.prompt()`.
424
+ // */
425
+ // public async focusToAlert(): Promise<Alert> {
426
+ // return this.driver.switchTo().alert();
427
+ // }
428
+ // /**
429
+ // * Enable file downloads in Chrome running in headless mode
430
+ // */
431
+ // private enableDownloadInHeadlessChrome(): void {
432
+ // /* eslint-disable no-underscore-dangle */
433
+ // const executor = (this.driver as any).getExecutor
434
+ // ? (this.driver as any).getExecutor()
435
+ // : (this.driver as any).executor_;
436
+ // /* eslint-enable no-underscore-dangle */
437
+ // executor.defineCommand(
438
+ // "send_command",
439
+ // "POST",
440
+ // "/session/:sessionId/chromium/send_command"
441
+ // );
442
+ // const params = {
443
+ // cmd: "Page.setDownloadBehavior",
444
+ // params: {
445
+ // behavior: "allow",
446
+ // downloadPath: WebBrowser.outDir
447
+ // }
448
+ // };
449
+ // this.driver.execute(new Command("send_command").setParameters(params));
450
+ // }
451
+ // /**
452
+ // * Wait for the download to complete.
453
+ // * @returns The name of the downloaded file.
454
+ // */
455
+ // // eslint-disable-next-line class-methods-use-this
456
+ // public async waitForDownload(params: {
457
+ // /** Function to start the download. */
458
+ // downloader: () => Promise<void>;
459
+ // /** Extension name of the file to download. */
460
+ // extname?: string;
461
+ // /** How long to wait, in milliseconds, for the download to complete. */
462
+ // timeout?: number;
463
+ // }): Promise<string> {
464
+ // const timeout = params.timeout || 30000;
465
+ // let extname = params.extname || "";
466
+ // if (extname && !extname.startsWith(".")) {
467
+ // extname = `.${extname}`;
468
+ // }
469
+ // Logger.debug("WebBrowser.download", { timeout, extname });
470
+ // const startedAt = Date.now();
471
+ // await params.downloader();
472
+ // // Omit the debug logs temporarily
473
+ // const logLevel = Logger.level;
474
+ // Logger.level = Logger.isInfoEnabled() ? "INFO" : Logger.level;
475
+ // try {
476
+ // while (Date.now() < startedAt + timeout) {
477
+ // const files = File.listFiles({
478
+ // sortType: File.SortType.Mtime,
479
+ // orderBy: File.OrderBy.DESC
480
+ // })
481
+ // .filter((filename): boolean => !filename.endsWith(".crdownload"))
482
+ // .filter((filename): boolean => filename.endsWith(extname));
483
+ // if (files.length > 0) {
484
+ // const latestFile = files[0];
485
+ // if (File.getStats({ filename: latestFile }).mtimeMs > startedAt) {
486
+ // return latestFile;
487
+ // }
488
+ // }
489
+ // await util.sleep(100); // eslint-disable-line no-await-in-loop
490
+ // }
491
+ // } finally {
492
+ // Logger.level = logLevel;
493
+ // }
494
+ // throw new Error("Download timed out");
495
+ // }
496
+ // /**
497
+ // * Refresh the current page.
498
+ // */
499
+ // public async refresh(): Promise<void> {
500
+ // await this.driver.navigate().refresh();
501
+ // }
502
+ // }
503
+ // }
504
+ // export default MR.WebBrowser.instance;
@@ -0,0 +1,123 @@
1
+ /// <reference types="node" />
2
+ import { Locator } from 'playwright';
3
+ import Robot from './Robot';
4
+ export declare namespace MR {
5
+ class WebElement {
6
+ private element;
7
+ private robotDetail;
8
+ constructor(ele: Locator, rd: Robot);
9
+ private printer;
10
+ /**
11
+ * Take a screenshot.
12
+ */
13
+ screenshot(params?: {
14
+ _filepath?: string;
15
+ _filename?: string;
16
+ }): Promise<Buffer>;
17
+ /**
18
+ * 滚动网页至元素可见
19
+ */
20
+ scrollIntoView(): Promise<void>;
21
+ /**
22
+ * 上传文件
23
+ */
24
+ setInputFiles(files: string | Array<string>, options?: {
25
+ noWaitAfter?: boolean;
26
+ timeout?: number;
27
+ }): Promise<void>;
28
+ /**
29
+ * 点击
30
+ */
31
+ click(options?: {
32
+ button?: "left" | "right" | "middle";
33
+ clickCount?: number;
34
+ delay?: number;
35
+ force?: boolean;
36
+ modifiers?: Array<"Alt" | "Control" | "Meta" | "Shift">;
37
+ noWaitAfter?: boolean;
38
+ position?: {
39
+ x: number;
40
+ y: number;
41
+ };
42
+ timeout?: number;
43
+ trial?: boolean;
44
+ }): Promise<void>;
45
+ dblclick(options?: {
46
+ button?: "left" | "right" | "middle";
47
+ delay?: number;
48
+ force?: boolean;
49
+ modifiers?: Array<"Alt" | "Control" | "Meta" | "Shift">;
50
+ noWaitAfter?: boolean;
51
+ position?: {
52
+ x: number;
53
+ y: number;
54
+ };
55
+ timeout?: number;
56
+ trial?: boolean;
57
+ }): Promise<void>;
58
+ clear(options?: {
59
+ force?: boolean;
60
+ noWaitAfter?: boolean;
61
+ timeout?: number;
62
+ }): Promise<void>;
63
+ dragTo(target: Locator): Promise<void>;
64
+ selectOption(values: null | string | Array<string> | {
65
+ value?: string;
66
+ label?: string;
67
+ index?: number;
68
+ } | Array<{
69
+ value?: string;
70
+ label?: string;
71
+ index?: number;
72
+ }>, options?: {
73
+ force?: boolean;
74
+ noWaitAfter?: boolean;
75
+ timeout?: number;
76
+ }): Promise<Array<string>>;
77
+ check(options?: {
78
+ force?: boolean;
79
+ noWaitAfter?: boolean;
80
+ position?: {
81
+ x: number;
82
+ y: number;
83
+ };
84
+ timeout?: number;
85
+ trial?: boolean;
86
+ }): Promise<void>;
87
+ uncheck(options?: {
88
+ force?: boolean;
89
+ noWaitAfter?: boolean;
90
+ position?: {
91
+ x: number;
92
+ y: number;
93
+ };
94
+ timeout?: number;
95
+ trial?: boolean;
96
+ }): Promise<void>;
97
+ fill(value: string, options?: {
98
+ force?: boolean;
99
+ noWaitAfter?: boolean;
100
+ timeout?: number;
101
+ }): Promise<void>;
102
+ innerHTML(options?: {
103
+ timeout?: number;
104
+ }): Promise<string>;
105
+ box(options?: {
106
+ timeout?: number;
107
+ }): Promise<null | {
108
+ x: number;
109
+ y: number;
110
+ width: number;
111
+ height: number;
112
+ }>;
113
+ innerText(options?: {
114
+ timeout?: number;
115
+ }): Promise<string>;
116
+ property(prop: 'isEnabled' | 'isEditable' | 'isChecked' | 'isDisabled' | 'isHidden' | 'isVisible', options?: {
117
+ timeout?: number;
118
+ }): Promise<boolean>;
119
+ private toStr;
120
+ }
121
+ }
122
+ declare const _default: typeof MR.WebElement;
123
+ export default _default;