POSTS / A Simpler Way to Install Chrome Browser and Chromedriver on WSL2 (Ubuntu 22.04)
Installing Google Chrome
As I have searched and seen so many posts instructing users to install a google chrome by local installation methods like dpkg
or rpm
, I’d prefer install via a very simple command:
$ sudo apt install google-chrome-stable
Installing ChromeDriver
Here I used a very traditional method to install a chrome driver.
First, I went to https://googlechromelabs.github.io/chrome-for-testing/#stable to find a proper version of chrome driver and then downloaded it into WSL2.
$ wget https://storage.googleapis.com/chrome-for-testing-public/123.0.6312.122/linux64/chromedriver-linux64.zip
Second, extract the downloaded ZIP file and move the executable file into somewhere (here I chose ~/.local/bin
).
$ unzip chromedriver-linux64.zip
$ mv chromedriver-linux64/chromedriver ~/.local/bin/chromedriver
Finally, check the permissions and whether ~/.local/bin
is in system path.
$ chmod +x ~/.local/bin/chromedriver
$ export PATH="$PATH:~/.local/bin"
Verify Google Chrome and ChromeDriver
Run the following commands and see whether they can work well.
$ google-chrome --version
$ chromedriver --version
Another Way to Install WebDrivers
As Selenium guide says, there have already been several driver management libraries:
- WebDriverManager (Java)
- WebDriver Manager (Python)
- WebDriver Manager Package (.NET)
- webdrivers gem (Ruby)
Maybe that’s a more elegant way to install a web driver. 🙂