0

I have a selenium script that works if launched manually (arm64 Ubuntu VM) while connected via ssh.

If I set it to run via crontab, it still works while ssh connection is active. Instead if I exit the connection, then it starts giving me this error:

2022-10-14 08:19:01,258 - root - INFO - Logging into stackoverflow.com
Traceback (most recent call last):
  File "/home/ubuntu/main/main.py", line 46, in <module>
    main()
  File "/home/ubuntu/main/main.py", line 20, in main
    log_return = login()
  File "/home/ubuntu/main/stack_overflow_page.py", line 37, in login
    driver = webdriver.Chrome(options=chrome_options)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
    super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "/home/ubuntu/.local/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 89, in __init__    self.service.start()
  File "/home/ubuntu/.local/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 98, in start
    self.assert_process_still_running()
  File "/home/ubuntu/.local/lib/python3.10/site-packages/selenium/webdriver/common/service.py", line 110, in assert_process_still_running
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 1

The script is running in headless mode and through pyvirtualdisplay. This is the relevant part of if:

chrome_options = Options()
chrome_options.add_argument("--headless")
display = Display(visible=False, size=(800, 600))
display.start()
driver = webdriver.Chrome(options=chrome_options)
albertopasqualetto
  • 87
  • 1
  • 1
  • 11

0 Answers0