Initialize the browser session and navigate to NotebookLM
(self)
| 49 | self._initialize() |
| 50 | |
| 51 | def _initialize(self): |
| 52 | """Initialize the browser session and navigate to NotebookLM""" |
| 53 | print(f"🚀 Creating session {self.id}...") |
| 54 | |
| 55 | # Create new page (tab) in context |
| 56 | self.page = self.context.new_page() |
| 57 | print(f" 🌐 Navigating to NotebookLM...") |
| 58 | |
| 59 | try: |
| 60 | # Navigate to notebook |
| 61 | self.page.goto(self.notebook_url, wait_until="domcontentloaded", timeout=30000) |
| 62 | |
| 63 | # Check if login is needed |
| 64 | if "accounts.google.com" in self.page.url: |
| 65 | raise RuntimeError("Authentication required. Please run auth_manager.py setup first.") |
| 66 | |
| 67 | # Wait for page to be ready |
| 68 | self._wait_for_ready() |
| 69 | |
| 70 | # Simulate human inspection |
| 71 | self.stealth.random_mouse_movement(self.page) |
| 72 | self.stealth.random_delay(300, 600) |
| 73 | |
| 74 | print(f"✅ Session {self.id} ready!") |
| 75 | |
| 76 | except Exception as e: |
| 77 | print(f"❌ Failed to initialize session: {e}") |
| 78 | if self.page: |
| 79 | self.page.close() |
| 80 | raise |
| 81 | |
| 82 | def _wait_for_ready(self): |
| 83 | """Wait for NotebookLM page to be ready""" |
no test coverage detected