Persistent sessions =================== The flagship feature: a browser created with a ``session`` name survives the Python process, and any later process can pick it up by name. .. code-block:: python import wabot bot = wabot.browser(session="scraper1", browser="firefox") bot.driver.get("https://example.com/login") # ... log in, then the process exits; the browser stays open ... # hours later, a different process: bot = wabot.browser(session="scraper1", browser="firefox") print(bot.driver.current_url) # still logged in How it works ------------ A session is just ``(executor_url, session_id)`` stored as JSON in the platform data dir. Nothing is pickled. The browser is hosted by a driver service that outlives Python: * **Managed (default):** wabot spawns chromedriver/geckodriver as a detached process and records its port and pid. * **External:** pass ``host="http://localhost:4444"`` to use a Selenium Grid or standalone server you run yourself. wabot then never kills the server — only the session. Reattaching constructs a driver that *adopts* the saved session id instead of creating a new session. Dead sessions (browser closed, server gone, record older than 3 days) are pruned automatically and a fresh browser is created instead. Housekeeping ------------ .. code-block:: python wabot.sessions() # ["scraper1", ...] wabot.destroy("scraper1") # quit browser, stop managed service, forget Selenium Grid caveat -------------------- Grid 4 kills idle sessions after **5 minutes** by default. If your process sleeps longer between reattaches, raise it:: java -jar selenium-server.jar standalone --session-timeout 86400