无法以无动于衷的方式制造 Python网络司机。
我正在使用108.0.5359.94号 Chrome版。
我也正在使用<条码>服务(Chrome/63/7rManager().install(),以自动安装兼容的hr网。
NOTE: The same result happens if I download the applicable chrome webdriver and instead of using the service I use the executable_path.
重新研究这一守则非常简单。
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
chrome_options = Options()
# chrome_options.add_argument( --headless )
chrome_options.add_argument( --remote-debugging-port=9222 )
chrome_options.add_argument( --no-sandbox )
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
print(driver)
在采用正常(并非无主)模式时,我正在得到网上用户物体的预期印刷:
python selenium_test.py
<selenium.webdriver.chrome.webdriver.WebDriver (session="9b6ec32017d8d864f8e2061293faee40")>
But when running in headless mode (same code simply remove the marker from the headless option line), I am getting the following error:
python selenium_test.py
Traceback (most recent call last):
File "/home/boazz/PycharmProjects/pythonProject/selenium_test.py", line 10, in <module>
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME[ browserName ], "goog",
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
super().__init__(
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 270, in __init__
self.start_session(capabilities, browser_profile)
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 363, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 428, in execute
self.error_handler.check_response(response)
File "/home/boazz/.virtualenvs/reigo_qa_39/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed.
(chrome not reachable)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x5588159a82a3 <unknown>
#1 0x558815766f77 <unknown>
#2 0x55881578f5f7 <unknown>
#3 0x55881578b7d0 <unknown>
#4 0x5588157cc0b7 <unknown>
#5 0x5588157cba5f <unknown>
#6 0x5588157c3903 <unknown>
#7 0x558815796ece <unknown>
#8 0x558815797fde <unknown>
#9 0x5588159f863e <unknown>
#10 0x5588159fbb79 <unknown>
#11 0x5588159de89e <unknown>
#12 0x5588159fca83 <unknown>
#13 0x5588159d1505 <unknown>
#14 0x558815a1dca8 <unknown>
#15 0x558815a1de36 <unknown>
#16 0x558815a39333 <unknown>
#17 0x7fa6443c0b43 <unknown>
我预计,无论我是否使用无头选择,都不会产生神职司机。 原因何在?