| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- const { chromium } = require('playwright');
- const fs = require('fs');
- (async () => {
- const browser = await chromium.launch({ headless: true, executablePath: 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe' });
- const page = await browser.newPage({ viewport: { width: 1800, height: 2000 } });
- const errors = [];
- page.on('pageerror', error => errors.push(error.message));
- await page.goto('http://127.0.0.1:8931/AI%E5%BF%AB%E9%80%9F%E6%8A%A5%E4%BB%B7_Demo2.html?v=zoom-position-test', { waitUntil: 'load' });
- const image = fs.readFileSync('C:/Users/miao/Downloads/494f54100a93c5a6e0c90f404c597514.jpeg').toString('base64');
- await page.evaluate(data => {
- qUploadedDrawing = { name:'zoom.jpeg', size:data.length, type:'image/jpeg' };
- qUploadedDrawingUrl = 'data:image/jpeg;base64,' + data;
- qUploadedDrawingDataUrl = qUploadedDrawingUrl;
- qStartAnalysis();
- }, image);
- await page.waitForTimeout(600);
- await page.locator('#q-floorplan-layout-workspace').scrollIntoViewIfNeeded();
- const tool = page.locator('.q-furniture-tool').filter({ hasText:'主卧衣柜' }).first();
- const workspace = page.locator('#q-floorplan-layout-workspace');
- const drawing = page.locator('#q-ai-cleaned-img');
- const ir = await drawing.boundingBox(), toolBox = await tool.boundingBox();
- const target1 = { x:ir.x + ir.width*.32, y:ir.y + ir.height*.43 };
- await page.mouse.move(toolBox.x+toolBox.width/2,toolBox.y+toolBox.height/2);
- await page.mouse.down();
- await page.mouse.move(target1.x,target1.y,{steps:10});
- await page.mouse.up();
- await page.waitForTimeout(150);
- const sticker = page.locator('.q-furniture-v3').first();
- const b1 = await sticker.boundingBox();
- const error1 = Math.hypot(b1.x+b1.width/2-target1.x, b1.y+b1.height/2-target1.y);
- const target2 = { x:ir.x + ir.width*.72, y:ir.y + ir.height*.62 };
- await page.mouse.move(b1.x+b1.width/2,b1.y+b1.height/2);
- await page.mouse.down();
- await page.mouse.move(target2.x,target2.y,{steps:8});
- await page.mouse.up();
- await page.waitForTimeout(100);
- const b2 = await sticker.boundingBox();
- const error2 = Math.hypot(b2.x+b2.width/2-target2.x, b2.y+b2.height/2-target2.y);
- const state = await page.evaluate(() => ({ zoom:getComputedStyle(document.body).zoom, item:qFurnitureLayout[0] }));
- await sticker.dblclick({ delay: 100 });
- await page.waitForTimeout(120);
- const remainingAfterDoubleClick = await page.locator('.q-furniture-v3').count();
- console.log(JSON.stringify({ errorAfterDrop:+error1.toFixed(2), errorAfterMove:+error2.toFixed(2), remainingAfterDoubleClick, state, errors }));
- await browser.close();
- })().catch(error => { console.error(error); process.exit(1); });
|