feat: add interactive geo drag models + chapter 1 questions + car path animation
This commit is contained in:
+77
@@ -0,0 +1,77 @@
|
||||
const { chromium } = require('playwright');
|
||||
|
||||
const htmlPath = 'C:\\Users\\然然小可爱\\Desktop\\数学乐园\\index.html';
|
||||
const fileUrl = 'file:///' + htmlPath.replace(/\\/g, '/');
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({ headless: true, args: ['--no-sandbox'] });
|
||||
const page = await browser.newPage({ viewport: { width: 800, height: 900 } });
|
||||
page.on('pageerror', e => console.log(' JS_ERROR:', e.message));
|
||||
|
||||
await page.goto(fileUrl, { timeout: 10000 }).catch(() => {});
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
console.log('=== 测试:EG例题流程 ===');
|
||||
|
||||
// 进入Ch1
|
||||
const cp0 = await page.$('.cp[data-idx="0"]');
|
||||
const b = await cp0.boundingBox();
|
||||
await page.mouse.click(b.x + b.width/2, b.y + b.height/2);
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
// 点 "发车" 进入KP
|
||||
await page.click('.act.show');
|
||||
await page.waitForTimeout(200);
|
||||
|
||||
// KP1继续、KP2继续、KP3继续 = 3次
|
||||
for (let i = 0; i < 3; i++) {
|
||||
await page.click('.act.show');
|
||||
await page.waitForTimeout(100);
|
||||
}
|
||||
|
||||
// 到达EG
|
||||
const egTitle = await page.$eval('.eg-title', e => e.textContent).catch(() => 'NO_EG');
|
||||
console.log('EG标题:', egTitle);
|
||||
|
||||
// 检查EG初始显示几个步骤
|
||||
const stepCnt = await page.$$eval('.eg-step', els => els.length);
|
||||
console.log('初始步骤数:', stepCnt);
|
||||
|
||||
// 检查按钮类型
|
||||
const btnId = await page.evaluate(() => {
|
||||
const btn = document.querySelector('.eg-btn, .act.show');
|
||||
return btn ? (btn.id || btn.className) : 'none';
|
||||
});
|
||||
console.log('初始按钮:', btnId);
|
||||
|
||||
// 逐步骤点击 "下一步"
|
||||
let clickCount = 0;
|
||||
while (true) {
|
||||
const egBtn = await page.$('#egBtn');
|
||||
if (!egBtn) break;
|
||||
await egBtn.click();
|
||||
await page.waitForTimeout(150);
|
||||
clickCount++;
|
||||
const steps = await page.$$eval('.eg-step.show', els => els.length);
|
||||
console.log('点击' + clickCount + '次后, 显示步骤:', steps, '/' + 5);
|
||||
}
|
||||
|
||||
console.log('总"下一步"点击:', clickCount);
|
||||
|
||||
// 现在应该出现 "继续" 按钮
|
||||
const hasContinue = await page.$('.act.show');
|
||||
console.log('有"继续"按钮:', hasContinue ? '✅' : '❌');
|
||||
|
||||
// 点击"继续"
|
||||
if (hasContinue) {
|
||||
await hasContinue.click();
|
||||
await page.waitForTimeout(300);
|
||||
const nextContent = await page.$eval('#cGl', e => e.textContent).catch(() => '');
|
||||
console.log('继续后内容:', nextContent);
|
||||
// 检查是否离开了EG
|
||||
const isStillEG = await page.$('.eg-title');
|
||||
console.log('是否还在EG页:', isStillEG ? '❌ 仍在该页面' : '✅ 已前进');
|
||||
}
|
||||
|
||||
await browser.close();
|
||||
})().catch(e => { console.log('失败:', e.message); process.exit(1); });
|
||||
Reference in New Issue
Block a user