I have a web scraper that uses Undetected Chromedriver & WebDriverManager to download & automate a Chromium webdriver.
On Windows I initialize the Undetcted Chromedriver instance by passing the executable_path
to the output of ChromeDriverManager().install()
. This works fine.
Now I am trying to Dockerize my application, however I am getting:
Error: expected str, bytes or os.PathLike object, not NoneType
when trying to initialize my object as lined out below. I'm not getting any other context to where the error is being raised from.
Driver initialisation
options = uc.ChromeOptions()
path = ChromeDriverManager(os_type="linux64").install()
driver = uc.Chrome(
options=options, executable_path=path, force=True
)
I've also tried:
- Check if the file at the path ChromeDriverManager.install() returns exists using
os.path.isfile()
which returned True - Pass a relative path to
executable_path
.
I don't quite know where it went wrong on my first Docker container but here's how I fixed it:
It seems like the ChromeDriver wasn't being downloaded properly. I'm guessing something to do with
$_PATH
variables.I installed the Chromedriver through docker by adding this to the Dockerfile
Which works great