35 lines
988 B
JavaScript
35 lines
988 B
JavaScript
const puppeteer = require('puppeteer');
|
|
const path = require('path');
|
|
|
|
(async () => {
|
|
const browser = await puppeteer.launch();
|
|
const page = await browser.newPage();
|
|
|
|
page.on('console', msg => {
|
|
if (msg.type() === 'error') {
|
|
console.log('PAGE ERROR:', msg.text());
|
|
} else {
|
|
console.log('PAGE LOG:', msg.text());
|
|
}
|
|
});
|
|
|
|
page.on('pageerror', error => {
|
|
console.log('PAGE EXCEPTION:', error.message);
|
|
console.log('STACK:', error.stack);
|
|
});
|
|
|
|
await page.goto('http://localhost:3000', { waitUntil: 'networkidle2' });
|
|
|
|
// Find the file input for import (usually has an accept=".glb,.gltf...")
|
|
const fileInput = await page.$('input[type="file"]');
|
|
if (fileInput) {
|
|
console.log('Found file input, uploading...');
|
|
await fileInput.uploadFile(path.resolve('C:/Users/900250.HCUDT299/Downloads/0.glb'));
|
|
await new Promise(r => setTimeout(r, 5000));
|
|
} else {
|
|
console.log('File input not found');
|
|
}
|
|
|
|
await browser.close();
|
|
})();
|