-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-debug.js
More file actions
63 lines (50 loc) · 1.97 KB
/
test-debug.js
File metadata and controls
63 lines (50 loc) · 1.97 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
const { chromium } = require('playwright');
(async () => {
try {
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext();
const page = await context.newPage();
// Navigate to login page
await page.goto('http://localhost:8080/wp-admin/');
// Check if already logged in or need to log in
const loginForm = await page.$('#loginform');
if (loginForm) {
console.log('Logging in...');
await page.fill('#user_login', 'admin');
await page.fill('#user_pass', '!3cTXkh)9iDHhV5o*N');
await page.click('#wp-submit');
await page.waitForSelector('.wrap', { timeout: 10000 });
}
console.log('Logged in successfully');
// Navigate to new post
await page.goto('http://localhost:8080/wp-admin/post-new.php');
console.log('Navigating to post editor...');
// Wait for editor to load
await page.waitForSelector('.wp-block-post-title', { timeout: 15000 });
console.log('Editor loaded successfully');
// Add some content
await page.fill('.wp-block-post-title', 'Test Post Title');
// Try to save the post
console.log('Attempting to save post...');
await page.keyboard.press('Control+s');
// Wait for save completion
await page.waitForTimeout(3000);
// Check for success or error messages
const saveMessage = await page.$('.editor-post-saved-state');
if (saveMessage) {
const saveText = await saveMessage.textContent();
console.log('Save status:', saveText);
}
const errorNotice = await page.$('.components-notice.is-error, .notice-error');
if (errorNotice) {
const errorText = await errorNotice.textContent();
console.log('ERROR FOUND:', errorText);
} else {
console.log('No errors detected during save');
}
await browser.close();
console.log('Test completed');
} catch (error) {
console.error('Test failed:', error.message);
}
})();