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:
os.path.isfile()
which returned Trueexecutable_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
RUN wget -q "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
RUN apt install -y ./google-chrome-stable_current_amd64.deb
RUN wget -q "https://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip" -O /tmp/chromedriver.zip \
&& unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/ \
&& rm /tmp/chromedriver.zip \
&& chmod +x /usr/local/bin/chromedriver
Which works great