Repository navigation
Expand file tree
/
Copy pathtest-playwright.js
More file actions
96 lines (81 loc) · 2.96 KB
/
Copy pathtest-playwright.js
File metadata and controls
96 lines (81 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({
headless: false,
devtools: true
});
const context = await browser.newContext();
const page = await context.newPage();
// Enable console logging
page.on('console', msg => {
console.log(`[Browser Console] ${msg.type()}: ${msg.text()}`);
});
// Log network requests for video files
page.on('request', request => {
const url = request.url();
if (url.includes('.m3u8') || url.includes('.mp4') || url.includes('.ts') || url.includes('divine')) {
console.log(`[Network Request] ${request.method()} ${url}`);
}
});
page.on('response', response => {
const url = response.url();
if (url.includes('.m3u8') || url.includes('.mp4') || url.includes('.ts') || url.includes('divine')) {
console.log(`[Network Response] ${response.status()} ${url}`);
}
});
// Log page errors
page.on('pageerror', error => {
console.log(`[Page Error] ${error.message}`);
});
console.log('Opening http://localhost:5173/debug-video ...');
await page.goto('http://localhost:5173/debug-video', { waitUntil: 'networkidle' });
// Wait for videos to load
await page.waitForTimeout(3000);
// Check if any video elements exist
const videoElements = await page.$$('video');
console.log(`Found ${videoElements.length} video elements on page`);
// Get video URLs from the debug page
const videoUrls = await page.evaluate(() => {
const urls = [];
document.querySelectorAll('code').forEach(code => {
const text = code.textContent;
if (text && (text.includes('.m3u8') || text.includes('.mp4'))) {
urls.push(text);
}
});
return urls;
});
console.log('\nVideo URLs found on page:');
videoUrls.forEach(url => console.log(` - ${url}`));
// Try clicking the first "Test This URL" button
const testButton = await page.$('button:has-text("Test This URL")');
if (testButton) {
console.log('\nClicking first "Test This URL" button...');
await testButton.click();
await page.waitForTimeout(5000);
// Check video state after clicking
const videoState = await page.evaluate(() => {
const video = document.querySelector('video');
if (!video) return null;
return {
src: video.src,
currentSrc: video.currentSrc,
readyState: video.readyState,
networkState: video.networkState,
error: video.error ? video.error.message : null,
paused: video.paused,
duration: video.duration,
buffered: video.buffered.length > 0 ? {
start: video.buffered.start(0),
end: video.buffered.end(0)
} : null
};
});
console.log('\nVideo element state:');
console.log(JSON.stringify(videoState, null, 2));
}
// Keep browser open for manual inspection
console.log('\nBrowser will stay open for inspection. Press Ctrl+C to close.');
// Keep the script running
await new Promise(() => {});
})();