Skip to content

Commit cd088c5

Browse files
author
Soul Browser
committed
fix: Update test script to use Playwright directly (no binary download needed)
1 parent 783207d commit cd088c5

1 file changed

Lines changed: 65 additions & 18 deletions

File tree

soulbrowser.py

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,81 @@
22
"""
33
Soul Browser Test Script
44
Opens https://telegram.org/support for 2 minutes in visible mode (no headless)
5+
Uses Playwright with stealth settings
56
"""
67

78
import time
8-
from soulbrowser import launch
9+
from playwright.sync_api import sync_playwright
910

1011
def main():
1112
print("🚀 Starting Soul Browser...")
1213
print("📍 Opening: https://telegram.org/support")
1314
print("⏱️ Will stay open for 2 minutes")
1415
print("-" * 50)
1516

16-
# Launch browser in visible mode (headless=False)
17-
browser = launch(headless=False)
18-
19-
# Create new page
20-
page = browser.new_page()
21-
22-
# Navigate to Telegram support
23-
page.goto("https://telegram.org/support", wait_until="domcontentloaded")
24-
25-
print(f"✅ Page loaded: {page.title()}")
26-
print("⏳ Waiting for 2 minutes...")
27-
28-
# Wait for 2 minutes (120 seconds)
29-
time.sleep(120)
30-
31-
print("🛑 Closing browser...")
32-
browser.close()
17+
with sync_playwright() as p:
18+
# Launch Chromium in visible mode with stealth args
19+
browser = p.chromium.launch(
20+
headless=False,
21+
args=[
22+
"--disable-blink-features=AutomationControlled",
23+
"--disable-infobars",
24+
"--disable-dev-shm-usage",
25+
"--disable-browser-side-navigation",
26+
"--disable-gpu-sandbox",
27+
"--no-first-run",
28+
"--no-service-autorun",
29+
"--password-store=basic",
30+
"--use-mock-keychain",
31+
"--disable-backgrounding-occluded-windows",
32+
"--disable-renderer-backgrounding",
33+
"--disable-background-timer-throttling",
34+
"--disable-ipc-flooding-protection",
35+
"--enable-features=NetworkService,NetworkServiceInProcess",
36+
]
37+
)
38+
39+
# Create context with realistic settings
40+
context = browser.new_context(
41+
viewport={"width": 1920, "height": 1080},
42+
user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
43+
locale="en-US",
44+
timezone_id="America/New_York",
45+
)
46+
47+
# Remove webdriver detection
48+
context.add_init_script("""
49+
Object.defineProperty(navigator, webdriver, {
50+
get: () => undefined
51+
});
52+
53+
// Overwrite plugins
54+
Object.defineProperty(navigator, plugins, {
55+
get: () => [1, 2, 3, 4, 5]
56+
});
57+
58+
// Overwrite languages
59+
Object.defineProperty(navigator, languages, {
60+
get: () => [en-US, en]
61+
});
62+
63+
// Hide automation
64+
window.chrome = { runtime: {} };
65+
""")
66+
67+
# Create page and navigate
68+
page = context.new_page()
69+
page.goto("https://telegram.org/support", wait_until="domcontentloaded")
70+
71+
print(f"✅ Page loaded: {page.title()}")
72+
print("⏳ Waiting for 2 minutes...")
73+
74+
# Wait for 2 minutes (120 seconds)
75+
time.sleep(120)
76+
77+
print("🛑 Closing browser...")
78+
browser.close()
79+
3380
print("✅ Done!")
3481

3582
if __name__ == "__main__":

0 commit comments

Comments
 (0)