Trying to understand why Selenium cannot see Binary at '/app/.apt/usr/bin/google-chrome' error despite solutions tried - using Heroku

Viewed 268

I am trying to use Selenium and Heroku I've run into a common error:

selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at '/app/.apt/usr/bin/google-chrome'

I've come across this article as to why this may be happening: WebDriverException: Message: unknown error: no chrome binary at C:/.../Chrome/Application/chrome.exe with ChromeDriver Selenium and Python

I am using Selenium 3.141.0

It suggests that Chromedriver is unable to locate the binary chrome.exe. It also suggests to ensure that I am not using the deprecated option: ChromeOptions() and don't believe I need to use the keyword argument executable_path as I am launching it from Heroku where I would use '/app/.apt/usr/bin/google-chrome' path. Other solutions I've come across suggests various different configurations and I feel like I have everything configured correctly but maybe not.

What else could be the reason that I am unable to get this to work?

Buildpacks

https://github.com/heroku/heroku-buildpack-google-chrome
https://github.com/heroku/heroku-buildpack-chromedriver

Heroku Config Variables

GOOGLE_CHROME_BINARY = "/app/.apt/usr/bin/google-chrome"
CHROMEDRIVER_PATH = "/app/.chromedriver/bin/chromedriver"

Options

class WebDriver:
def __init__(self):
    self.GOOGLE_CHROME_BINARY = config('GOOGLE_CHROME_BINARY')
    self.CHROMEDRIVER_PATH = config('CHROMEDRIVER_PATH')
    self.chrome_options = Options()
    self.chrome_options.add_argument("--disable-dev-shm-usage")
    self.chrome_options.add_argument('--no-sandbox')
    self.chrome_options.binary_location = self.GOOGLE_CHROME_BINARY
    self.chrome_options.add_argument("headless")
    self.driver = webdriver.Chrome(self.CHROMEDRIVER_PATH, options=self.chrome_options)

Any help even in just helping me understand what's going on better would be much appreciated

0 Answers
Related