MsRewards/V7/tools/browser_setup.py

19 lines
725 B
Python
Raw Normal View History

2024-01-18 20:15:58 +01:00
from playwright.sync_api import sync_playwright, expect, Page, BrowserContext
from playwright_stealth import stealth_sync
from pyvirtualdisplay.smartdisplay import SmartDisplay
def create_display(vnc=False) -> SmartDisplay:
if vnc:
return SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=2345, color_depth=24)
return SmartDisplay(size=(1920, 1080))
def start_browser(name: str) -> (Page, BrowserContext):
p = sync_playwright().start()
browser = p.firefox.launch_persistent_context(f"./data/{name}/", headless=False, args=["--start-maximised"],
no_viewport=True)
page = browser.new_page()
stealth_sync(page)
return page, browser