在运行Ubuntu Server22.04的Raspberry PI 4上使用Selify运行一个Python脚本。铬浏览器ChromeDriver V 103.0.5060.53(当前稳定通过https://chromedriver.chromium.org/)
当我在终端中运行该脚本时,一切都按预期运行,但是,当该脚本通过cron作业执行时,该脚本失败并显示以下错误:
Traceback (most recent call last):
File "/home/ubuntu/code.py", line 59, in <module>
driver = webdriver.Chrome(service=Service('/usr/lib/chromium-browser/chromedriver'), options=chrome_options)
File "/home/ubuntu/.local/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in __init__
super(WebDriver, self).__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 /usr/lib/chromium-browser/chromedriver unexpectedly exited. Status code was: 1
下面是我配置驱动程序的方式:
chrome_options = Options()
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--headless')
chrome_options.add_argument('start_maximized')
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
chrome_options.add_argument("disable-infobars")
driver = webdriver.Chrome(service=Service('/usr/lib/chromium-browser/chromedriver'), options=chrome_options)
找不到状态代码为1或ASSERT_PROCESS_STY_RUNNING的任何故障排除,因此,如果有任何帮助,我们将不胜感激:)
1条答案
按热度按时间von4xj4u1#
我也有同样的问题。我发现,如果我更新CRONTAB,则下一次运行将成功,但后续运行将失败,状态为1。
因此,我创建了一个脚本来自动更新我的cron作业将运行的时间,这很麻烦,但它很有帮助。
然后,我将其创建为cronTab的一个条目,并且它每天午夜更新cronTab