提问人:M3RS 提问时间:9/26/2023 更新时间:9/26/2023 访问量:95
带有 Chrome 的 Selenium 适用于一个用户,但不适用于另一个用户
Selenium with Chrome works for one user, but not another
问:
我在 Ubuntu 22.04 上有两个用户。它们在 Python 3.10.12 的虚拟环境中都有相同的包。
selenium==4.2.0
webdriver-manager==4.0.1
他们都能够执行:chrome
$ ls -al /opt/google/chrome/chrome
-rwxr-xr-x 1 root root 229088456 Sep 20 23:10 /opt/google/chrome/chrome
对于其中一个,下面的运行正常,而对于另一个,我收到一个错误。
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
options = webdriver.ChromeOptions()
options.add_argument('headless')
wdm = ChromeDriverManager()
selenium = webdriver.Chrome(wdm.install(), options=options)
第二个用户的错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/testing/testing/testing_env/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/testing/testing/testing_env/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
RemoteWebDriver.__init__(
File "/home/testing/testing/testing_env/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 275, in __init__
self.start_session(capabilities, browser_profile)
File "/home/testing/testing/testing_env/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 365, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/testing/testing/testing_env/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 430, in execute
self.error_handler.check_response(response)
File "/home/testing/testing/testing_env/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome failed to start: exited normally.
(session not created: DevToolsActivePort file doesn't exist)
(The process started from chrome location /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x559104ccb6b3 <unknown>
#1 0x5591049a11e7 <unknown>
#2 0x5591049d4526 <unknown>
#3 0x5591049d069c <unknown>
#4 0x559104a1323a <unknown>
#5 0x559104a09e93 <unknown>
#6 0x5591049dc934 <unknown>
#7 0x5591049dd71e <unknown>
#8 0x559104c90cb8 <unknown>
#9 0x559104c94bf0 <unknown>
#10 0x559104c9f19c <unknown>
#11 0x559104c95808 <unknown>
#12 0x559104c6227f <unknown>
#13 0x559104cb9e88 <unknown>
#14 0x559104cba059 <unknown>
#15 0x559104cca843 <unknown>
#16 0x7f8c8ba94b43 <unknown>
有什么想法可以检查以追踪此错误吗?也许环境不同,或者两个Chrome实例之间存在冲突,但我不知道还有什么要检查的。
答: 暂无答案
评论
ps aux | grep chrom