-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_selector.py
More file actions
68 lines (54 loc) · 2.49 KB
/
test_selector.py
File metadata and controls
68 lines (54 loc) · 2.49 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
#!/usr/bin/env python3
"""
Quick test script to verify WhatsApp Web selectors
"""
import asyncio
from playwright.async_api import async_playwright
async def test_selectors():
"""Test WhatsApp Web selectors"""
async with async_playwright() as p:
browser = await p.chromium.launch(headless=False)
page = await browser.new_page()
print("🌐 Navigating to WhatsApp Web...")
await page.goto("https://web.whatsapp.com")
print("⏳ Waiting for page to load...")
await asyncio.sleep(10)
print("🔍 Testing selectors...")
# Test selectors
selectors_to_test = [
'p.selectable-text.copyable-text',
'div[contenteditable="true"][data-tab="10"]',
'div[contenteditable="true"][role="textbox"]',
'p[contenteditable="true"]',
'div[contenteditable="true"]'
]
for selector in selectors_to_test:
try:
elements = await page.query_selector_all(selector)
print(f"✅ {selector}: Found {len(elements)} elements")
if elements:
for i, element in enumerate(elements[:3]): # Check first 3 elements
tag_name = await element.evaluate('el => el.tagName')
classes = await element.evaluate('el => el.className')
parent = await element.evaluate('el => el.parentElement ? el.parentElement.tagName : "none"')
print(f" Element {i+1}: <{tag_name}> classes='{classes}' parent=<{parent}>")
except Exception as e:
print(f"❌ {selector}: Error - {e}")
print("\n🔍 Looking for chat-related elements...")
chat_selectors = [
'[data-testid="conversation-panel-wrapper"]',
'[role="application"]',
'footer',
'[data-testid="compose-box"]'
]
for selector in chat_selectors:
try:
elements = await page.query_selector_all(selector)
print(f"📱 {selector}: Found {len(elements)} elements")
except Exception as e:
print(f"❌ {selector}: Error - {e}")
print("\n⏳ Keeping browser open for 30 seconds for manual inspection...")
await asyncio.sleep(30)
await browser.close()
if __name__ == "__main__":
asyncio.run(test_selectors())