import { BrowserScraper } from './build/scraper/browser_scraper.js';
async function testBrowserDownload() {
console.log('🚀 Testing Browser Scraper - Download All Years');
console.log('═'.repeat(50));
console.log('This test will:');
console.log('1. Expand the Årsregnskap section');
console.log('2. Click "Vis alle" to show all years');
console.log('3. Download all PDFs (2012-2024)');
console.log('═'.repeat(50));
const orgNr = '999059198'; // KONGOLO CONSULTING AS
const scraper = new BrowserScraper();
console.log(`\n📊 Testing with company: ${orgNr}`);
console.log('─'.repeat(50) + '\n');
try {
const startTime = Date.now();
// Get all financial years
const results = await scraper.getAllFinancialYears(orgNr);
const duration = Math.round((Date.now() - startTime) / 1000);
console.log('\n' + '═'.repeat(50));
console.log('📊 RESULTS');
console.log('═'.repeat(50));
console.log(`\n✅ Total years found: ${results.length}`);
console.log(`⏱️ Time taken: ${duration} seconds\n`);
// List all years
const years = results.map(r => r.year).sort((a, b) => a - b);
console.log(`📅 Years available: ${years.join(', ')}`);
// Summary
if (results.length >= 13) {
console.log('\n🎉 SUCCESS! Found all years (2012-2024)!');
} else if (results.length > 3) {
console.log(`\n✅ Better! Found ${results.length} years (expecting 13 years: 2012-2024)`);
} else {
console.log(`\n⚠️ Only found ${results.length} years. Expected 13 years (2012-2024)`);
}
// Show which years have data
console.log('\n📊 Years with extracted data:');
results.forEach(year => {
if (year.revenue || year.profit || year.assets || year.equity) {
console.log(` ${year.year}: Source=${year.source}`);
}
});
} catch (error) {
console.error('\n❌ Test failed:', error);
console.error('\nMake sure Chrome is installed at /Applications/Google Chrome.app');
}
console.log('\n' + '═'.repeat(50));
console.log('Test complete!\n');
}
testBrowserDownload();