UNPKG

@auto-browse/auto-browse

Version:
31 lines (30 loc) 908 B
class SessionManager { static instance; currentPage = null; currentContext = null; constructor() { } static getInstance() { if (!SessionManager.instance) SessionManager.instance = new SessionManager(); return SessionManager.instance; } setPage(page) { this.currentPage = page; } setContext(context) { this.currentContext = context; } getPage() { if (!this.currentPage) { throw new Error('No active page found. Make sure you are running within a Playwright test.'); } return this.currentPage; } getContext() { if (!this.currentContext) { throw new Error('No active browser context found. Make sure you are running within a Playwright test.'); } return this.currentContext; } } export const sessionManager = SessionManager.getInstance();