mirror of
https://github.com/web-infra-dev/midscene.git
synced 2025-12-28 07:30:02 +00:00
chore: optimize code style (#77)
This commit is contained in:
parent
952d13e8b0
commit
e071adfa70
16
.vscode/settings.json
vendored
16
.vscode/settings.json
vendored
@ -3,20 +3,6 @@
|
||||
"source.organizeImports.biome": "explicit"
|
||||
},
|
||||
"editor.defaultFormatter": "biomejs.biome",
|
||||
"eslint.validate": [
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"vue",
|
||||
"html"
|
||||
],
|
||||
"eslint.nodePath": "node_modules",
|
||||
"eslint.trace.server": "verbose",
|
||||
"eslint.workingDirectories": [
|
||||
{
|
||||
"mode": "auto"
|
||||
}
|
||||
],
|
||||
"editor.formatOnSave": true,
|
||||
"editor.formatOnSaveMode": "modifications"
|
||||
}
|
||||
|
||||
@ -37,6 +37,7 @@ export default defineConfig({
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: 'on-first-retry',
|
||||
deviceScaleFactor: process.platform === 'darwin' ? 2 : 1, // Device scaling factor
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import type { Page as PlaywrightPage } from 'playwright';
|
||||
import type { KeyInput, Page as PuppeteerPage } from 'puppeteer';
|
||||
|
||||
export type WebPage = PlaywrightPage | PuppeteerPage;
|
||||
export type WebPage = (PlaywrightPage | PuppeteerPage) & {
|
||||
evaluate<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): Promise<R>;
|
||||
};
|
||||
export type WebKeyInput = KeyInput;
|
||||
|
||||
@ -52,7 +52,7 @@ export class PageTaskExecutor {
|
||||
}
|
||||
|
||||
private async recordScreenshot(timing: ExecutionRecorderItem['timing']) {
|
||||
const file = getTmpFile('jpeg');
|
||||
const file = getTmpFile('png');
|
||||
await this.page.screenshot({
|
||||
...commonScreenshotParam,
|
||||
path: file,
|
||||
|
||||
@ -22,6 +22,7 @@ export async function parseContextFromWebPage(
|
||||
|
||||
const url = page.url();
|
||||
const file = getTmpFile('jpeg');
|
||||
|
||||
await page.screenshot({ path: file, type: 'jpeg', quality: 75 });
|
||||
const screenshotBuffer = readFileSync(file);
|
||||
const screenshotBase64 = base64Encoded(file);
|
||||
@ -51,7 +52,7 @@ export async function getElementInfosFromPage(page: WebPage) {
|
||||
const elementInfosScriptContent = readFileSync(scriptPath, 'utf-8');
|
||||
const extraReturnLogic = `${elementInfosScriptContent}midscene_element_inspector.extractTextWithPosition()`;
|
||||
|
||||
const captureElementSnapshot = await (page as any).evaluate(extraReturnLogic);
|
||||
const captureElementSnapshot = await page.evaluate(extraReturnLogic);
|
||||
return captureElementSnapshot as Array<ElementInfo>;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user