L
L
Lexx Xell2021-05-11 17:18:02
selenium
Lexx Xell, 2021-05-11 17:18:02

How to disable automatic session closing in Selenium+Firefox?

I am making a parser bot, it works on Selenium+Firefox. It is necessary to constantly work from under one session, but when idle, after some time, the channel closes, and with it the session:

selenium_1  | 12:49:14.243 INFO [ActiveSessions$1.onStop] - Removing session 1bbe1550-852e-4602-bfc2-532d67d3fbbf (org.openqa.selenium.firefox.GeckoDriverService)
selenium_1  | 1620737354261     Marionette      INFO    Stopped listening on port 35195
selenium_1  | 
selenium_1  | ###!!! [Parent][RunMessage] Error: Channel closing: too late to send/recv, messages will be lost


How to disable automatic closing of a session, or how to resume a closed session?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lexx Xell, 2021-05-11
@LexxXell

As a solution, use a profile created in advance (in which authentication has already been completed in the desired service), and connect it at startup:

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.firefox.options import Options as FirefoxOptnions

webdriver_host = "http://127.0.0.1:4444/wd/hub"
desired_capabilities = DesiredCapabilities.FIREFOX

options = FirefoxOptnions()
# Вот тут указываем путь к папке профиля
options.profile = "../profiles/c63u9jz2.default-release-1" 

driver = webdriver.Remote(
    webdriver_host,
    desired_capabilities,
    options=options,
)

This will allow the session to be resumed on restarts.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question