test-chromium.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Chromium集成测试脚本
  2. const { chromium } = require('playwright');
  3. async function testChromium() {
  4. console.log('🧪 测试Chromium集成...');
  5. try {
  6. // 启动Chromium
  7. console.log('🚀 启动Chromium浏览器...');
  8. const browser = await chromium.launch({
  9. headless: true,
  10. args: [
  11. '--no-sandbox',
  12. '--disable-setuid-sandbox',
  13. '--disable-dev-shm-usage'
  14. ]
  15. });
  16. // 创建新页面
  17. console.log('📄 创建新页面...');
  18. const page = await browser.newPage();
  19. // 导航到Steam主页
  20. console.log('🌐 导航到Steam...');
  21. await page.goto('https://store.steampowered.com/');
  22. // 检查页面标题
  23. const title = await page.title();
  24. console.log('📋 页面标题:', title);
  25. // 检查是否成功加载Steam页面
  26. if (title.includes('Steam')) {
  27. console.log('✅ Steam页面加载成功');
  28. } else {
  29. console.log('❌ Steam页面加载失败');
  30. }
  31. // 关闭浏览器
  32. await browser.close();
  33. console.log('🎉 Chromium集成测试通过!');
  34. } catch (error) {
  35. console.error('❌ Chromium测试失败:', error.message);
  36. process.exit(1);
  37. }
  38. }
  39. // 运行测试
  40. testChromium();