0

I've a small script using selenium running in Docker container :

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import os

try:
    use_service = True
    path_driver =  os.getcwd() + "/drivers/chromedriver"
    options = webdriver.ChromeOptions()
    options.add_argument("--headless")
    options.add_argument("--disable-gpu")
    options.add_argument("--no-sandbox")

    if use_service:
        print("---> use Service()")
        from selenium.webdriver.chrome.service import Service
        service = Service(path_driver)
        driver = webdriver.Chrome(service=service, options=options)
    else:
        driver = webdriver.Chrome(path_driver,options=options)


    driver.get(my_url)
    driver.find_element(By.ID, "login").send_keys("bar")    
    driver.find_element(By.ID, "pass").send_keys("foo")
    driver.find_element(By.NAME, "OK").send_keys(Keys.RETURN)

    urls = { "04": "https://xxx.xx/xxx/xxx","05": "https://xxx.xx/xxx/xxx",}

    for dept, url in urls.items():
        driver.get(url)
        print(len(driver.page_source))

    driver.close()
    driver.quit()

except Exception as e:
    print("ERROR ", str(e))

On the server, it's working, but some times in the container, it crash afte on this line "driver.find_element(By.NAME, "OK").send_keys(Keys.RETURN)" :

---> use Service()
ERROR  Message: unknown error: session deleted because of page crash
from unknown error: cannot determine loading status
from tab crashed
  (Session info: headless chrome=111.0.5563.64)
Stacktrace:
#0 0x556474bfed93 <unknown>
#1 0x5564749cd15d <unknown>
#2 0x5564749b908c <unknown>
#3 0x5564749b8531 <unknown>
#4 0x5564749b75bb <unknown>
#5 0x5564749b7404 <unknown>
#6 0x5564749b5ee2 <unknown>
#7 0x5564749b6682 <unknown>
#8 0x5564749c3b4f <unknown>
#9 0x5564749c47a2 <unknown>
#10 0x5564749d4ba0 <unknown>
#11 0x5564749d8e40 <unknown>
#12 0x5564749b6b43 <unknown>
#13 0x5564749d47dc <unknown>
#14 0x556474a4583a <unknown>
#15 0x556474a2d353 <unknown>
#16 0x5564749fce40 <unknown>
#17 0x5564749fe038 <unknown>
#18 0x556474c528be <unknown>
#19 0x556474c568f0 <unknown>
#20 0x556474c36f90 <unknown>
#21 0x556474c57b7d <unknown>
#22 0x556474c28578 <unknown>
#23 0x556474c7c348 <unknown>
#24 0x556474c7c4d6 <unknown>
#25 0x556474c96341 <unknown>
#26 0x7f92ba72ffa3 start_thread

I've try on the same server not using docker, simply install selenium, and it's working.

Informations :

Docker : Linux 40b5ec9c18f9 5.15.0-58-generic #64-Ubuntu SMP Thu Jan 5 11:43:13 UTC 2023 x86_64 GNU/Linux

System : Linux valabre-prod23 5.15.0-58-generic #64-Ubuntu SMP Thu Jan 5 11:43:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

$ google-chrome --version Google Chrome 111.0.5563.64

$ chromedriver --version ChromeDriver 110.0.5481.77 (65ed616c6e8ee3fe0ad64fe83796c020644d42af-refs/branch-heads/5481@{#839})

Can you help me please ? Thanks

F.

fabrice
  • 1,399
  • 1
  • 15
  • 27

1 Answers1

0

This error message...

ERROR  Message: unknown error: session deleted because of page crash
from unknown error: cannot determine loading status
from tab crashed

...implies that ChromeDriver crashed while interacting with the client.

You are facing this crash possibly is due to incompatibility between the version of the binaries you are using.


Solution

Ensure that:


References

You can find a couple of relevant detailed discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352