forked from eran-broder/playwright-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-page.html
More file actions
646 lines (597 loc) · 20.4 KB
/
test-page.html
File metadata and controls
646 lines (597 loc) · 20.4 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Playwright Server Test Page</title>
<style>
* {
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background: #f5f5f5;
}
h1 {
color: #333;
border-bottom: 2px solid #007bff;
padding-bottom: 10px;
}
.section {
background: white;
padding: 20px;
margin: 20px 0;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.section h2 {
margin-top: 0;
color: #555;
}
input[type="text"], input[type="email"], textarea, select {
width: 100%;
padding: 10px;
margin: 8px 0;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 14px;
}
button {
background: #007bff;
color: white;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
margin: 5px 5px 5px 0;
}
button:hover {
background: #0056b3;
}
button.secondary {
background: #6c757d;
}
button.secondary:hover {
background: #545b62;
}
button.success {
background: #28a745;
}
button.success:hover {
background: #1e7e34;
}
button.danger {
background: #dc3545;
}
button.danger:hover {
background: #c82333;
}
#output {
background: #1e1e1e;
color: #0f0;
padding: 15px;
border-radius: 4px;
font-family: 'Consolas', 'Monaco', monospace;
min-height: 100px;
white-space: pre-wrap;
font-size: 13px;
}
.counter {
display: flex;
align-items: center;
gap: 15px;
}
.counter span {
font-size: 24px;
font-weight: bold;
min-width: 50px;
text-align: center;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
}
th, td {
border: 1px solid #ddd;
padding: 10px;
text-align: left;
}
th {
background: #f8f9fa;
}
tr:hover {
background: #f5f5f5;
}
.checkbox-group label {
display: block;
margin: 8px 0;
}
.checkbox-group input {
margin-right: 8px;
}
.tabs {
display: flex;
border-bottom: 2px solid #ddd;
margin-bottom: 15px;
}
.tab {
padding: 10px 20px;
cursor: pointer;
border: none;
background: none;
color: #666;
font-size: 14px;
}
.tab.active {
color: #007bff;
border-bottom: 2px solid #007bff;
margin-bottom: -2px;
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
}
.modal-overlay {
display: none;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.5);
z-index: 1000;
}
.modal {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: white;
padding: 30px;
border-radius: 8px;
z-index: 1001;
min-width: 300px;
}
.modal h3 {
margin-top: 0;
}
#dynamic-list {
list-style: none;
padding: 0;
}
#dynamic-list li {
padding: 10px;
margin: 5px 0;
background: #f8f9fa;
border-radius: 4px;
display: flex;
justify-content: space-between;
align-items: center;
}
#dynamic-list li button {
padding: 5px 10px;
font-size: 12px;
}
.progress-bar {
width: 100%;
height: 20px;
background: #e9ecef;
border-radius: 10px;
overflow: hidden;
}
.progress-fill {
height: 100%;
background: linear-gradient(90deg, #007bff, #28a745);
transition: width 0.3s ease;
}
#status-indicator {
display: inline-block;
width: 12px;
height: 12px;
border-radius: 50%;
background: #28a745;
margin-right: 8px;
}
</style>
</head>
<body>
<h1>Playwright Server Test Page</h1>
<p><span id="status-indicator"></span>Status: <span id="page-status">Ready</span></p>
<!-- Form Section -->
<div class="section">
<h2>Form Elements</h2>
<form id="test-form">
<label for="username">Username:</label>
<input type="text" id="username" name="username" placeholder="Enter username">
<label for="email">Email:</label>
<input type="email" id="email" name="email" placeholder="Enter email">
<label for="message">Message:</label>
<textarea id="message" name="message" rows="3" placeholder="Enter your message"></textarea>
<label for="country">Country:</label>
<select id="country" name="country">
<option value="">Select a country</option>
<option value="us">United States</option>
<option value="uk">United Kingdom</option>
<option value="de">Germany</option>
<option value="fr">France</option>
<option value="jp">Japan</option>
</select>
<div class="checkbox-group">
<label><input type="checkbox" id="check1" name="options" value="option1"> Option 1</label>
<label><input type="checkbox" id="check2" name="options" value="option2"> Option 2</label>
<label><input type="checkbox" id="check3" name="options" value="option3"> Option 3</label>
</div>
<button type="submit">Submit Form</button>
<button type="reset" class="secondary">Reset</button>
</form>
</div>
<!-- Counter Section -->
<div class="section">
<h2>Interactive Counter</h2>
<div class="counter">
<button id="decrement" class="danger">-</button>
<span id="counter-value">0</span>
<button id="increment" class="success">+</button>
</div>
<div style="margin-top: 15px;">
<button id="reset-counter" class="secondary">Reset Counter</button>
</div>
</div>
<!-- Tabs Section -->
<div class="section">
<h2>Tabbed Content</h2>
<div class="tabs">
<button class="tab active" data-tab="tab1">Tab 1</button>
<button class="tab" data-tab="tab2">Tab 2</button>
<button class="tab" data-tab="tab3">Tab 3</button>
</div>
<div id="tab1" class="tab-content active">
<h3>First Tab Content</h3>
<p>This is the content of the first tab. It contains some sample text for testing.</p>
</div>
<div id="tab2" class="tab-content">
<h3>Second Tab Content</h3>
<p>This is the content of the second tab. Different content appears here.</p>
</div>
<div id="tab3" class="tab-content">
<h3>Third Tab Content</h3>
<p>This is the content of the third tab. Each tab can be independently selected.</p>
</div>
</div>
<!-- Dynamic List Section -->
<div class="section">
<h2>Dynamic List</h2>
<div style="display: flex; gap: 10px; margin-bottom: 10px;">
<input type="text" id="new-item" placeholder="Enter new item" style="flex: 1;">
<button id="add-item" class="success">Add Item</button>
</div>
<ul id="dynamic-list">
<li>Sample Item 1 <button class="danger delete-btn">Delete</button></li>
<li>Sample Item 2 <button class="danger delete-btn">Delete</button></li>
</ul>
</div>
<!-- Table Section -->
<div class="section">
<h2>Data Table</h2>
<table id="data-table">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>John Doe</td>
<td>john@example.com</td>
<td>Active</td>
</tr>
<tr>
<td>2</td>
<td>Jane Smith</td>
<td>jane@example.com</td>
<td>Pending</td>
</tr>
<tr>
<td>3</td>
<td>Bob Wilson</td>
<td>bob@example.com</td>
<td>Inactive</td>
</tr>
</tbody>
</table>
</div>
<!-- Progress Section -->
<div class="section">
<h2>Progress Bar</h2>
<div class="progress-bar">
<div class="progress-fill" id="progress-fill" style="width: 0%"></div>
</div>
<p>Progress: <span id="progress-value">0</span>%</p>
<button id="start-progress">Start Progress</button>
<button id="reset-progress" class="secondary">Reset</button>
</div>
<!-- Network API Testing Section -->
<div class="section">
<h2>Network API Testing</h2>
<p>Test network requests for monitoring with Playwright Server:</p>
<div style="display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 15px;">
<button id="fetch-json" class="success">Fetch JSON</button>
<button id="fetch-users">Fetch Users</button>
<button id="fetch-posts">Fetch Posts</button>
<button id="post-data">POST Data</button>
<button id="fetch-error" class="danger">Trigger 404</button>
</div>
<div id="api-result" style="background: #f8f9fa; padding: 15px; border-radius: 4px; font-family: monospace; font-size: 12px; max-height: 200px; overflow-y: auto; white-space: pre-wrap;">API results will appear here...</div>
</div>
<!-- Async Activity Testing Section -->
<div class="section">
<h2>Async Activity Testing</h2>
<p>Test various async behaviors that happen between commands:</p>
<div style="display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 15px;">
<button id="delayed-fetch" class="success">Delayed Fetch (2s)</button>
<button id="periodic-fetch">Periodic Fetches (3x)</button>
<button id="console-burst">Console Burst</button>
<button id="trigger-error" class="danger">Trigger Error</button>
<button id="show-alert">Show Alert</button>
<button id="websocket-sim">WebSocket Sim</button>
</div>
<div id="async-status" style="background: #e9ecef; padding: 10px; border-radius: 4px; font-size: 13px;">Async status: idle</div>
</div>
<!-- Modal Section -->
<div class="section">
<h2>Modal Dialog</h2>
<button id="open-modal">Open Modal</button>
</div>
<div class="modal-overlay" id="modal-overlay">
<div class="modal">
<h3>Modal Dialog</h3>
<p>This is a modal dialog. You can interact with it or close it.</p>
<input type="text" id="modal-input" placeholder="Enter something...">
<div style="margin-top: 15px;">
<button id="modal-confirm" class="success">Confirm</button>
<button id="modal-close" class="secondary">Close</button>
</div>
</div>
</div>
<!-- Output Section -->
<div class="section">
<h2>Console Output</h2>
<div id="output">Waiting for actions...</div>
<button id="clear-output" class="secondary">Clear Output</button>
</div>
<script>
const output = document.getElementById('output');
const pageStatus = document.getElementById('page-status');
function log(message) {
const timestamp = new Date().toLocaleTimeString();
output.textContent += `\n[${timestamp}] ${message}`;
output.scrollTop = output.scrollHeight;
}
// Form handling
document.getElementById('test-form').addEventListener('submit', (e) => {
e.preventDefault();
const formData = new FormData(e.target);
const data = Object.fromEntries(formData.entries());
log('Form submitted: ' + JSON.stringify(data));
pageStatus.textContent = 'Form Submitted';
});
// Counter
let counter = 0;
const counterValue = document.getElementById('counter-value');
document.getElementById('increment').addEventListener('click', () => {
counter++;
counterValue.textContent = counter;
log('Counter incremented to ' + counter);
});
document.getElementById('decrement').addEventListener('click', () => {
counter--;
counterValue.textContent = counter;
log('Counter decremented to ' + counter);
});
document.getElementById('reset-counter').addEventListener('click', () => {
counter = 0;
counterValue.textContent = counter;
log('Counter reset');
});
// Tabs
document.querySelectorAll('.tab').forEach(tab => {
tab.addEventListener('click', () => {
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
tab.classList.add('active');
document.getElementById(tab.dataset.tab).classList.add('active');
log('Switched to ' + tab.textContent);
});
});
// Dynamic list
function addDeleteListeners() {
document.querySelectorAll('.delete-btn').forEach(btn => {
btn.onclick = function() {
const item = this.parentElement;
const text = item.textContent.replace('Delete', '').trim();
item.remove();
log('Deleted item: ' + text);
};
});
}
addDeleteListeners();
document.getElementById('add-item').addEventListener('click', () => {
const input = document.getElementById('new-item');
const value = input.value.trim();
if (value) {
const li = document.createElement('li');
li.innerHTML = `${value} <button class="danger delete-btn">Delete</button>`;
document.getElementById('dynamic-list').appendChild(li);
addDeleteListeners();
log('Added item: ' + value);
input.value = '';
}
});
// Progress bar
let progressInterval;
document.getElementById('start-progress').addEventListener('click', () => {
let progress = 0;
const fill = document.getElementById('progress-fill');
const value = document.getElementById('progress-value');
clearInterval(progressInterval);
progressInterval = setInterval(() => {
progress += 5;
fill.style.width = progress + '%';
value.textContent = progress;
log('Progress: ' + progress + '%');
if (progress >= 100) {
clearInterval(progressInterval);
log('Progress complete!');
pageStatus.textContent = 'Progress Complete';
}
}, 200);
});
document.getElementById('reset-progress').addEventListener('click', () => {
clearInterval(progressInterval);
document.getElementById('progress-fill').style.width = '0%';
document.getElementById('progress-value').textContent = '0';
log('Progress reset');
});
// Modal
document.getElementById('open-modal').addEventListener('click', () => {
document.getElementById('modal-overlay').style.display = 'block';
log('Modal opened');
});
document.getElementById('modal-close').addEventListener('click', () => {
document.getElementById('modal-overlay').style.display = 'none';
log('Modal closed');
});
document.getElementById('modal-confirm').addEventListener('click', () => {
const input = document.getElementById('modal-input').value;
document.getElementById('modal-overlay').style.display = 'none';
log('Modal confirmed with: ' + (input || '(empty)'));
pageStatus.textContent = 'Modal Confirmed';
});
// Clear output
document.getElementById('clear-output').addEventListener('click', () => {
output.textContent = 'Waiting for actions...';
});
// Network API Testing
const apiResult = document.getElementById('api-result');
async function fetchAndDisplay(url, options = {}) {
apiResult.textContent = 'Loading...';
log('Fetching: ' + url);
try {
const response = await fetch(url, options);
const data = await response.json();
apiResult.textContent = JSON.stringify(data, null, 2);
log('Fetch completed: ' + response.status + ' ' + response.statusText);
return data;
} catch (error) {
apiResult.textContent = 'Error: ' + error.message;
log('Fetch failed: ' + error.message);
}
}
document.getElementById('fetch-json').addEventListener('click', () => {
fetchAndDisplay('https://jsonplaceholder.typicode.com/todos/1');
});
document.getElementById('fetch-users').addEventListener('click', () => {
fetchAndDisplay('https://jsonplaceholder.typicode.com/users?_limit=3');
});
document.getElementById('fetch-posts').addEventListener('click', () => {
fetchAndDisplay('https://jsonplaceholder.typicode.com/posts?_limit=3');
});
document.getElementById('post-data').addEventListener('click', () => {
fetchAndDisplay('https://jsonplaceholder.typicode.com/posts', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
title: 'Test Post',
body: 'This is a test post from Playwright Server',
userId: 1
})
});
});
document.getElementById('fetch-error').addEventListener('click', () => {
fetchAndDisplay('https://jsonplaceholder.typicode.com/nonexistent/404');
});
// Async Activity Testing
const asyncStatus = document.getElementById('async-status');
document.getElementById('delayed-fetch').addEventListener('click', () => {
asyncStatus.textContent = 'Async status: waiting 2 seconds before fetch...';
log('Starting delayed fetch (will happen in 2 seconds)');
setTimeout(async () => {
console.log('[Async] Delayed fetch starting now');
asyncStatus.textContent = 'Async status: fetching...';
await fetchAndDisplay('https://jsonplaceholder.typicode.com/todos/2');
asyncStatus.textContent = 'Async status: delayed fetch complete';
console.log('[Async] Delayed fetch completed');
}, 2000);
});
document.getElementById('periodic-fetch').addEventListener('click', () => {
let count = 0;
asyncStatus.textContent = 'Async status: starting periodic fetches...';
log('Starting periodic fetches (3 requests, 1 second apart)');
const interval = setInterval(async () => {
count++;
console.log(`[Periodic] Fetch ${count}/3 starting`);
asyncStatus.textContent = `Async status: periodic fetch ${count}/3`;
await fetchAndDisplay(`https://jsonplaceholder.typicode.com/todos/${count}`);
if (count >= 3) {
clearInterval(interval);
asyncStatus.textContent = 'Async status: periodic fetches complete';
console.log('[Periodic] All fetches completed');
}
}, 1000);
});
document.getElementById('console-burst').addEventListener('click', () => {
asyncStatus.textContent = 'Async status: generating console messages';
log('Generating console burst');
console.log('[Console Test] Regular log message');
console.info('[Console Test] Info message');
console.warn('[Console Test] Warning message');
console.error('[Console Test] Error message (not a real error)');
console.debug('[Console Test] Debug message');
console.log('[Console Test] Object:', { key: 'value', nested: { a: 1, b: 2 } });
console.log('[Console Test] Array:', [1, 2, 3, 'four', { five: 5 }]);
asyncStatus.textContent = 'Async status: console burst complete';
});
document.getElementById('trigger-error').addEventListener('click', () => {
asyncStatus.textContent = 'Async status: triggering error...';
log('Triggering JavaScript error');
setTimeout(() => {
// This will throw a real error that the activity recorder should catch
throw new Error('Test error triggered intentionally for activity recording');
}, 100);
});
document.getElementById('show-alert').addEventListener('click', () => {
asyncStatus.textContent = 'Async status: showing alert';
log('Showing alert dialog');
alert('This is a test alert! The activity recorder should capture this dialog.');
asyncStatus.textContent = 'Async status: alert dismissed';
});
document.getElementById('websocket-sim').addEventListener('click', () => {
asyncStatus.textContent = 'Async status: simulating websocket activity';
log('Simulating WebSocket-like periodic updates');
let msgCount = 0;
const ws = setInterval(() => {
msgCount++;
console.log(`[WebSocket Sim] Message ${msgCount}: ${JSON.stringify({ type: 'update', data: Math.random() })}`);
if (msgCount >= 5) {
clearInterval(ws);
asyncStatus.textContent = 'Async status: websocket simulation complete';
console.log('[WebSocket Sim] Connection closed');
}
}, 500);
});
// Log initial state
log('Test page loaded and ready');
</script>
</body>
</html>