[Notes] chromedriver download and installation method


When automated testing or crawling web page data is required, the Chrome browser driver (ChromeDriver) is a key component. It allows to control and interact with the Chrome browser. In this article, I will introduce how to download and install ChromeDriver.

What is ChromeDriver

ChromeDriver is a driver for automation control and interaction with Google Chrome browser. It is an open source project of the Chrome browser, developed and maintained by the Chrome development team.

ChromeDriver allows developers to write scripts using programming languages ​​(such as Python, Java, C#, etc.) to control the behavior of the Chrome browser. With ChromeDriver, you can simulate various actions that users perform in the browser, such as opening web pages, filling out forms, clicking buttons, scrolling pages, etc. This makes automated testing and web scraping easier and more efficient.

ChromeDriver corresponds to a specific version of Chrome browser, so before using ChromeDriver, you need to make sure to install the version of ChromeDriver that matches the version of Chrome browser you are currently using. This ensures that ChromeDriver can properly communicate and control the browser.

ChromeDriver is widely used in automated testing, web crawling, web page screenshots, performance testing and other fields. It provides developers with a convenient way to control and manage the Chrome browser for various automation tasks.

It should be noted that installing and using ChromeDriver requires certain technical knowledge and programming experience. But once you master the basic usage, you can make full use of the functions of ChromeDriver to improve the efficiency of development and testing.

download and install

setp1: Check Chrome browser version

First, you need to check the version of your Chrome browser. Please follow the steps below:

  1. Open the Chrome browser.
  2. Click the menu icon (three vertical dots) in the upper right corner of your browser.
  3. Select Help.
  4. Select "About Google Chrome" from the drop-down menu.
    Please add a picture description

This will open a new tab showing the version number of the currently installed Chrome browser. Make a note of this version number, as you will need to ensure that you download the ChromeDriver that matches your version of Chrome.

insert image description here

step2: Download ChromeDriver

Once you know the version number of the Chrome browser, you can start to download the corresponding version of ChromeDriver. Please follow the steps below:

  1. Open the ChromeDriver official download page: https://sites.google.com/a/chromium.org/chromedriver/downloads
  2. On the download page, you will see a list of Chrome browser version numbers and the corresponding ChromeDriver version numbers.
  3. Find the version of ChromeDriver that matches the version number of your Chrome browser, and click the download link.

Please note that the download file of ChromeDriver is a compressed file, according to the operating system, select the appropriate download file.

insert image description here

Taobao mirror: https://registry.npmmirror.com/binary.html?path=chromedriver/

Official mirror: https://sites.google.com/a/chromium.org/chromedriver/downloads

step3: install ChromeDriver

Now that the ChromeDriver download is complete, unzip it and add it to your system's PATH environment variable. Please follow the steps below:

  1. Unzip the downloaded ChromeDriver compressed file to the browser installation directory: C:\Program Files (x86)\Google\Chrome\Application

    (according to your actual installation directory)
    insert image description here

insert image description here

  1. In the operating system, find the environment variable settings for the system.

    The following are the environment variable setting locations of several common operating systems:

    • Windows: Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables.
    • macOS: Enter "nano ~/.bash_profile" in the terminal to edit the bash profile file.
    • Linux: Enter "nano ~/.bashrc" in the terminal to edit the bashrc file.
  2. In the environment variable settings, find the variable named "PATH" and add the path of ChromeDriver to its value. For example, if you extracted ChromeDriver to "C:\chromedriver" (Windows) or "/usr/local/bin/chromedriver" (macOS/Linux), you need to add that path to your PATH variable.

insert image description here

After saving and closing the environment variable settings file, be sure to restart the Terminal or Command Prompt window for the environment variable changes to take effect.

step4: Verify the installation

Once the installation is complete, you can verify that ChromeDriver is correctly installed and available. Please follow the steps below:

  1. Open a terminal or command prompt window.
  2. Type "chromedriver" (macOS/Linux) or "chromedriver.exe" (Windows).
  3. If the installation was successful, you will see the version information of ChromeDriver along with some other output.

insert image description here

This means that ChromeDriver has been successfully installed and it has been added to the system's PATH environment variable.

Summarize

By following the steps above, ChromeDriver can be downloaded and installed easily. Remember to make sure you download the ChromeDriver that matches your version of Chrome and add it properly to your system's PATH environment variable.

I hope this article is helpful, and let ChromeDriver be used smoothly for automated testing and web page data crawling. Good luck!insert image description here

Guess you like

Origin blog.csdn.net/mingfeng4923/article/details/130989513
Recommended