Chromedriver_autoinstaller 还在工作吗?
Is Chromedriver_autoinstaller still working?
我愿意运行chromedriver_autoinstaller
。我在这里遵循示例:https://pypi.org/project/chromedriver-autoinstaller/
from selenium import webdriver
import chromedriver_autoinstaller
chromedriver_autoinstaller.install() # Check if the current version of chromedriver exists
# and if it doesn't exist, download it automatically,
# then add chromedriver to path
driver = webdriver.Chrome()
driver.get("http://www.python.org")
assert "Python" in driver.title
但是我得到一个错误:
Traceback (most recent call last):
File "/usr/lib/python3.8/code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 9, in <module>
File "/home/vojtam/Desktop/greads_scrape/venv/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 76, in __init__
RemoteWebDriver.__init__(
File "/home/vojtam/Desktop/greads_scrape/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/home/vojtam/Desktop/greads_scrape/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/vojtam/Desktop/greads_scrape/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/home/vojtam/Desktop/greads_scrape/venv/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist
这是什么意思?这个包还在用吗?
这个错误信息...
org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist
...意味着 ChromeDriver 无法 initiate/spawn 一个新的 WebBrowser 即 Chrome 浏览器 会话。
A common cause for Chrome to crash during startup is running Chrome as root
user (administrator
) on Linux. While it is possible to work around this issue by passing --no-sandbox
flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged. You need to configure your environment to run Chrome as a regular user instead.
以普通用户身份执行测试。
参考资料
您可以在以下位置找到一些详细的讨论:
- unknown error: DevToolsActivePort file doesn't exist error while executing Selenium UI test cases on ubuntu
- Tests fail immediately with unknown error: DevToolsActivePort file doesn't exist when running Selenium grid through systemd
我愿意运行chromedriver_autoinstaller
。我在这里遵循示例:https://pypi.org/project/chromedriver-autoinstaller/
from selenium import webdriver
import chromedriver_autoinstaller
chromedriver_autoinstaller.install() # Check if the current version of chromedriver exists
# and if it doesn't exist, download it automatically,
# then add chromedriver to path
driver = webdriver.Chrome()
driver.get("http://www.python.org")
assert "Python" in driver.title
但是我得到一个错误:
Traceback (most recent call last):
File "/usr/lib/python3.8/code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 9, in <module>
File "/home/vojtam/Desktop/greads_scrape/venv/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 76, in __init__
RemoteWebDriver.__init__(
File "/home/vojtam/Desktop/greads_scrape/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/home/vojtam/Desktop/greads_scrape/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/vojtam/Desktop/greads_scrape/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/home/vojtam/Desktop/greads_scrape/venv/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist
这是什么意思?这个包还在用吗?
这个错误信息...
org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist
...意味着 ChromeDriver 无法 initiate/spawn 一个新的 WebBrowser 即 Chrome 浏览器 会话。
A common cause for Chrome to crash during startup is running Chrome as
root
user (administrator
) on Linux. While it is possible to work around this issue by passing--no-sandbox
flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged. You need to configure your environment to run Chrome as a regular user instead.
以普通用户身份执行测试。
参考资料
您可以在以下位置找到一些详细的讨论:
- unknown error: DevToolsActivePort file doesn't exist error while executing Selenium UI test cases on ubuntu
- Tests fail immediately with unknown error: DevToolsActivePort file doesn't exist when running Selenium grid through systemd