Как установить chromedriver на windows

от admin

Install browser drivers

Through WebDriver, Selenium supports all major browsers on the market such as Chrome/Chromium, Firefox, Internet Explorer, Edge, and Safari. Where possible, WebDriver drives the browser using the browser’s built-in support for automation.

Since all the driver implementations except for Internet Explorer are provided by the browser vendors themselves, they are not included in the standard Selenium distribution. This section explains the basic requirements for getting started with the different browsers.

Read about more advanced options for starting a driver in our driver configuration documentation.

Four Ways to Use Drivers

1. Selenium Manager (Beta)

Selenium Manager helps you to get a working environment to run Selenium out of the box. Beta 1 of Selenium Manager will configure the drivers for Chrome, Firefox, and Edge if they are not found on the PATH . No extra configuration is needed. Future releases of Selenium Manager will eventually even download browsers if necessary.

Read more at the blog announcement for Selenium Manager .

2. Driver Management Software

Most machines automatically update the browser, but the driver does not. To make sure you get the correct driver for your browser, there are many third party libraries to assist you.

Installing Selenium and Chromedriver on Windows

If you want to use Selenium to scrape web sites with Chrome, just follow these steps!

This article assumes the reader knows the following:

  1. How to open a Python interpreter in a command prompt or how to run a Python script
  2. What ‘web scraping’ is
  3. Why a person would want to use Selenium and chromediver to accomplish their scraping task

Step 1: Download and install Google Chrome

You probably already have Chrome installed, but if you don’t, you can get it here.

Step 2: Download Chromedriver and store it somewhere

Chromedriver is produced by the team behind Chrome and allows Chrome to be automatically controlled by Selenium. This is the trickiest step.

  1. Get to the latest release of chromedriver by going to the official download page.
  2. Click through until you see a page that looks like this and click on your version to download it.

3. Unzip the downloaded file

4. Move the chromedriver.exe file to a permanent home. It’s easiest to place it in c:\windows because that directory is already a part of the system path. If you choose to store it somewhere else (e.g. c:\selenium like I do), you’ll need to add that directory to your path. Here’s some instructions on how to do that.

Step 3: Install selenium using pip

  1. Open up your Windows Command Prompt (or cmder if you’re cool)
  2. If you’re using Conda or Virtualenv, fire up the environment you want to use (if you don’t know what this is, just skip it for now and do some googling later!)
  3. Run the following

Step 4: Test it out!

Читать:
Что такое системное программирование

Here’s some Python code that you can run to make sure that your setup is working. It should pop up a Chrome window, take you to the NASA website, and then print out the headlines from that site.

Getting started

This page documents how to start using ChromeDriver for testing your website on desktop (Windows/Mac/Linux) .

ChromeDriver is a separate executable that Selenium WebDriver uses to control Chrome. It is maintained by the Chromium team with help from WebDriver contributors. If you are unfamiliar with Selenium WebDriver, you should check out the Selenium site .

Follow these steps to setup your tests for running with ChromeDriver:

Ensure Chromium/Google Chrome is installed in a recognized location

ChromeDriver expects you to have Chrome installed in the default location for your platform. You can also force ChromeDriver to use a custom location by setting a special capability.

Download the ChromeDriver binary for your platform under the downloads section of this site

Help WebDriver find the downloaded ChromeDriver executable

Установка драйвера chromedriver для Chrome Selenium

Для запуска тестов Selenium в Google Chrome, помимо самого браузера Chrome, должен быть установлен ChromeDriver. Установить ChromeDriver очень просто, так как он находится в свободном доступе в Интернете. Загрузите архив в зависимости от операционной системы, разархивируйте его и поместите исполняемый файл chromedriver в нужную директорию.

Какую версию chromedriver установить?

Мы должны установить именно ту версия которая была бы совместима с установленным Google Chrome на нашем ПК или VDS. В случае, если версии не совпадают, то мы получим данную ошибку:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81

Введите в адресную строку Google Chrome данный путь:

У вас появится вот такое окно:

Версия chromedriver

Рисунок 1 — Узнаем версию браузера Google Chrome

Скачать ChromeDriver для Linux, Windows и Mac

На данный момент актуальная версия драйвера 81.0.40 хотя у меня установлен более старый Google Chrome и последняя версия мне не подойдет. Как видно на рисунке выше, мне нужна версия 79.0.39 у вас может быть другая версия, нужно её скачать.

Скачать драйвер ChromeDriver

Рисунок 2 — Официальный сайт Google для загрузки драйвера chromedriver

На момент прочтения этой статьи версия может быть другой. Всегда выбирайте более новую версию, чтобы не поймать старые баги которые уже давно исправили в новой версии. НО! Помните, что вам нужно обновить и свой браузер Google Chrome если вы хотите работать с новой версией ChromeDriver.

Установка ChromeDriver под Linux, Windows и Mac

  1. Заходим на сайт https://chromedriver.storage.googleapis.com/index.html?path=79.0.3945.36/ (Проверьте сайт с Рис. 2 на обновления, тут версия: 79.0.3945);
  2. Скачиваем архив под вашу операционную систему;
  3. Распаковываем файл и запоминаем где находится файл chromedriver или chromedriver.exe (Windows).

Архив Chromedriver

Рисунок 3 — Скаченный архив с ChromeDriver

Если у вас Linux дистрибутив или Mac, вам нужно дать файлу chromedriver нужные права на выполнения. Открываем терминал и вводим команды одна за другой.

Похожие статьи