- How to Download & Install Selenium WebDriver
- Step 1 – Install Java Software Development Kit (JDK)
- Step 2 – Install Eclipse IDE
- Step 3 – Selenium WebDriver Installation
- Step 4 – Configure Eclipse IDE with WebDriver
- Different Drivers
- Summary
- Гайд по Selenium. Часть 1. Установка Selenium WebDriver
- Шаг 1. Устанавливаем Java
- Шаг 2. Устанавливаем Eclipse IDE
- Шаг 3. Скачиваем Selenium Java Client Driver
- Шаг 4. Настраиваем Eclipse для работы с WebDriver
- Другие драйвера
- Где скачать
How to Download & Install Selenium WebDriver
NOTE: The versions of Java, Eclipse, Selenium will keep updating with time. But the installation steps will remain the same. Please select the latest version and continue the installation steps below-
Step 1 – Install Java Software Development Kit (JDK)
Download and install the Java Software Development Kit (JDK) here.
This JDK version comes bundled with Java Runtime Environment (JRE), so you do not need to download and install the JRE separately.
Once installation is complete, open command prompt and type “java”. If you see the following screen you are good to move to the next step.
Step 2 – Install Eclipse IDE
Download the latest version of “Eclipse IDE for Java Developers” here. Be sure to choose correctly between Windows 32 Bit and 64 Bit versions.
You should be able to download an exe file named “eclipse-inst-win64” for Setup.
Double-click on a file to Install the Eclipse. A new window will open. Click Eclipse IDE for Java Developers.
After that, a new window will open which click button marked 1 and change path to “C:\eclipse”. Post that Click on the Install button marked 2
After successful completion of the installation procedure, a window will appear. On that window click on Launch.
This will start eclipse neon IDE for you.
Step 3 – Selenium WebDriver Installation
You can download Selenium Webdriver for Java Client Driver here. You will find client drivers for other languages there, but only choose the one for Java.
This download comes as a ZIP file named “selenium-3.14.0.zip”. For simplicity of Selenium installation on Windows 10, extract the contents of this ZIP file on your C drive so that you would have the directory “C:\selenium-3.14.0\”. This directory contains all the JAR files that we would later import on Eclipse for Selenium setup.
Step 4 – Configure Eclipse IDE with WebDriver
- Launch the “eclipse.exe” file inside the “eclipse” folder that we extracted in step 2. If you followed step 2 correctly, the executable should be located on C:\eclipse\eclipse.exe.
- When asked to select for a workspace, just accept the default location.
3. Create a new project through File > New > Java Project. Name the project as “newproject”.
A new pop-up window will open. Enter details as follow
- Project Name
- Location to save a project
- Select an execution JRE
- Select the layout project option
- Click on the Finish button
- Right-click on the newly created project and
- Select New > Package, and name that package as “newpackage”.
A pop-up window will open to name the package,
5. Create a new Java class under newpackage by right-clicking on it and then selecting- New > Class, and then name it as “MyClass”. Your Eclipse IDE should look like the image below.
When you click on Class, a pop-up window will open, enter details as
This is how it looks like after creating class.
Now selenium WebDriver’s into Java Build Path
- Right-click on “newproject” and select Properties.
- On the Properties dialog, click on “Java Build Path”.
- Click on the Libraries tab, and then
- Click on “Add External JARs..”
When you click on “Add External JARs..” It will open a pop-up window. Select the JAR files you want to add.
After selecting jar files, click on OK button.
Select all files inside the lib folder.
Select files outside lib folder
Once done, click “Apply and Close” button
6. Add all the JAR files inside and outside the “libs” folder. Your Properties dialog should now look similar to the image below.
7. Finally, click OK and we are done importing Selenium libraries into our project.
Different Drivers
HTMLUnit is the only browsers that WebDriver can directly automate – meaning that no other separate component is needed to install or run while the test is being executed. For other browsers, a separate program is needed. That program is called as the Driver Server.
A driver server is different for each browser. For example, Internet Explorer has its own driver server which you cannot use on other browsers. Below is the list of driver servers and the corresponding browsers that use them.
You can download these drivers here
Browser | Name of Driver Server | Remarks |
---|---|---|
HTMLUnit | HtmlUnitDriver | WebDriver can drive HTMLUnit using HtmlUnitDriver as driver server |
Firefox | Mozilla GeckoDriver | WebDriver can drive Firefox without the need of a driver server Starting Firefox 45 & above one needs to use gecko driver created by Mozilla for automation |
Internet Explorer | Internet Explorer Driver Server | Available in 32 and 64-bit versions. Use the version that corresponds to the architecture of your IE |
Chrome | ChromeDriver | Though its name is just “ChromeDriver”, it is, in fact, a Driver Server, not just a driver. The current version can support versions higher than Chrome v.21 |
Opera | OperaDriver | Though its name is just “OperaDriver”, it is, in fact, a Driver Server, not just a driver. |
PhantomJS | GhostDriver | PhantomJS is another headless browser, just like HTMLUnit. |
Safari | SafariDriver | Though its name is just “SafariDriver”, it is, in fact, a Driver Server, not just a driver. |
Summary
Aside from a browser, you will need the following to start using WebDriver
- Java Development Kit (JDK).https://www.oracle.com/java/technologies/downloads/
- Eclipse IDE – http://www.eclipse.org/downloads/
- Java Client Driver – https://www.selenium.dev/downloads/
When starting a WebDriver project in Eclipse, do not forget to import the Java Client Driver files onto your project. These files will constitute your Selenium Library.
With a new version of Selenium, there is no browser that you can automate without the use of a Driver Server.
Гайд по Selenium. Часть 1. Установка Selenium WebDriver
В этом гайде мы разберем, как установить Selenium WebDriver.
Примечание: Версии Java, Eclipse и Selenium постоянно обновляются. Но порядок действий для установки не зависит от этих версий. Просто выбирайте последние версии и выполняйте шаги этого руководства.
Шаг 1. Устанавливаем Java
Скачиваем и устанавливаем Java Software Development Kit (JDK). Скачать можно по ссылке.
JDK включает в себя и Java Runtime Environment (JRE), поэтому не нужно скачивать и устанавливать его отдельно.
После завершения установки открываем командную строку и вводим java . Если ваша консоль выглядит так же, как на изображении ниже, можно переходить к следующему шагу.
Шаг 2. Устанавливаем Eclipse IDE
Скачиваем актуальную версию Eclipse IDE for Java Developers (дистрибутив по ссылке). Если вы работаете в Windows, обратите внимание, что есть отдельные версии Eclipse для 32-разрядных и 64-разрядных архитектур.
После скачивания устанавливаем Eclipse:
Выбираем Eclipse IDE for Java Developers:
В Installation Folder указываем папку, в которую нужно установить Eclipse (мы выбираем c:\Eclipse )
После завершения установки запускаем Eclipse:
Шаг 3. Скачиваем Selenium Java Client Driver
Скачиваем Selenium WebDriver for Java Client Drivder (cсылка). На этой странице можно найти драйвера для разных языков программирования — нас интересует драйвер для Java.
После скачивания у вас будет ZIP-архив с названием «selenium-java-3.141.59.zip» (возможно, версия будет отличаться). Распаковываем содержимое архива. В распакованной папке будут находиться все необходимые JAR-файлы, которые мы потом импортируем в Eclipse.
Шаг 4. Настраиваем Eclipse для работы с WebDriver
2. При выборе workspace, выбираем папку по умолчанию.
3. Создаем новый проект (File > New > Java Project). Вводим имя проекта (в нашем случае это будет «newproject»)
В следующем окне устанавливаем следующие конфигурации:
- Имя проекта
- Папка проекта
- Окружения для запуска (execution JRE)
- Layout проекта
После этого нажимаем «Finish».
4. Нажимаем правой кнопкой мыши на созданном проекте и выбираем New > Package. Вводим имя пакета (в нашем случае это будет newpackage)
5. В новом пакете создаем Java-класс. Кликаем правой кнопкой мыши по пакету и выбираем New > Class. Вводим имя класса (в нашем случае это будет NewClass).
После создания класса IDE должна выглядеть, как на изображении ниже:
Добавим Selenium WebDriver в Java Build Path
- Кликаем правой кнопкой мыши по проекту («newproject») и выбираем Properties.
- В окне Properties нажимаем на Java Build Path.
- Выбираем вкладку Libraries и нажимаем на Add External JARs…
После клика по Add External JARs… должно открыться окно выбора JAR-файлов.
Выбираем все файлы внутри папки libs:
Выбираем файлы внутри папки Library:
После добавления нажимаем Apply and Close:
6. После добавления необходимых JAR-файлов ваш проект должен выглядеть как на изображении ниже:
Поздравляем, мы завершили импорт Selenium в наш проект!
Другие драйвера
HTMLUnit и Firefox — браузеры, которыми WebDriver может управлять напрямую — это значит, что для работы с ними не нужно устанавливать никакие другие драйвера. Для остальных браузеров нужно дополнительное ПО — Driver Server.
Эти драйвера разные для разных браузеров. Например, драйвер для IE можно использовать только вместе с IE, для других браузеров он не подойдет.
Где скачать
Кроме браузера, для использования WebDriver, понадобятся:
- Java Development Kit (JDK). Скачать можно здесь.
- Eclipse IDE. Скачать можно здесь.
- Java Client Driver. Скачать можно здесь.
Важно не забывать импортировать файлы драйвера в Eclipse проект.