Делал все по-порядку:
Дальше добавил переменные:
Написал соответствующие строчки кода:
chrome_options = Options()
chrome_options.binary_location = os.getenv('GOOGLE_CHROME_BIN')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('-- headless')
browser = webdriver.Chrome(executable_path=os.getenv('CHROMEDRIVER_PATH'),
chrome_options=chrome_options)
Ошибка в итоге:
solving_the_test.main 2022-10-11 13:14:58,194 Thread-1 (main) CRITICAL Error appeared while creating chromedriver
Traceback (most recent call last):
File "/app/solving_the_test/main.py", line 31, in main
browser = webdriver.Chrome(
File "/app/.heroku/python/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/app/.heroku/python/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
super().__init__(
File "/app/.heroku/python/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 272, in __init__
self.start_session(capabilities, browser_profile)
File "/app/.heroku/python/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 364, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/app/.heroku/python/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute
self.error_handler.check_response(response)
File "/app/.heroku/python/lib/python3.10/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: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /app/.apt/opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x55e9ef57e2c3 <unknown>
#1 0x55e9ef38783a <unknown>
#2 0x55e9ef3ad543 <unknown>
#3 0x55e9ef3a8546 <unknown>
#4 0x55e9ef3e6de6 <unknown>
#5 0x55e9ef3e674f <unknown>
#6 0x55e9ef3ded63 <unknown>
#7 0x55e9ef3b37e3 <unknown>
#8 0x55e9ef3b4a21 <unknown>
#9 0x55e9ef5cc18e <unknown>
#10 0x55e9ef5cf622 <unknown>
#11 0x55e9ef5b2aae <unknown>
#12 0x55e9ef5d02a3 <unknown>
#13 0x55e9ef5a6ecf <unknown>
#14 0x55e9ef5f0588 <unknown>
#15 0x55e9ef5f0706 <unknown>
#16 0x55e9ef60a8b2 <unknown>
#17 0x7fbb6cfaeb43 <unknown>