You are here: Ultra Guide>Automation Web>SettingUpWebDrivers (25 Jun 2020, LiamBarrett)Edit AttachTags

Setting Up Webdrivers

This page explains how to set up the drivers required for Selenium Webdriver usage. This tutorial currently only covers Windows 10 and Python, but may be expanded in the future. To follow this tutorial make sure to install Python if you haven't already.

Download a Driver

In order to use Selenium Webdriver, you need to download a driver for the browser you intend to test. You use ChromeDriver for Chrome, GeckoDriver for Firefox, and IEDriver for Internet Explorer. Using Edge requires a bit more explaining - I will cover that later. Save the driver to a location of your choice, bearing in mind that the chosen folder will be where the driver lives from now on. I recommend storing all your web drivers in the same location, as it means you won't need to repeat this process again for subsequent drivers. Keep this location on hand - the file path is needed for the next step.
webdrivers_01_folder.png

Set up the PATH

Once you have the driver downloaded, you will need to set up the environment variable to enable it. Press the Windows key to open the Start menu.
webdrivers_02_start_menu.png

Without clicking any of the options, start typing - this will bring up the search menu. Type "environment", then select Edit the system environment variables.
webdrivers_03_start_search.png

In the following menu, select Environment Variables. Select the variable named Path and click Edit.
webdrivers_04_properties_edit.png

At this point, open the folder with the driver inside it if it isn't already open. Click on the address bar and copy the contents.
webdrivers_05_copy_path.png

Back in the Edit environment variable window, select New, and paste the copied folder path into the text field, then select OK on all the windows that have been opened up to this point.
webdrivers_06_new_path.png

Install Selenium

Open the Start menu again. This time, type "command" and select Command Console.
webdrivers_07_cmd.png

Copy the following code, then right-click in the Command Console to paste it and hit Enter. (Because I already have it installed, it skips the installation.)
pip install -U selenium

webdrivers_08_install_selenium.png

Using Edge

Using Edge requires a bit more setup. The method to enable Edge usage depends on the version. For versions prior to 18, download Microsoft Edge Legacy from the list on the right. This acts the same as the other drivers. webdrivers_09_edge_driver.png

However, versions 18 and later require the Command Prompt. Open the Start menu again. Type "command" again, and this time, right-click Command Prompt and select Run as administrator.
webdrivers_10_cmd_admin.png

Copy the following code and paste it into the Command Prompt by right-clicking.
webdrivers_11_enable_edge.png
DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0

Import and Use Selenium

At the top of the .py file, enter the following line of code.
from selenium import webdriver

When you go to actually open the browser, use one of the following code lines, depending on the desired browser.
browser = webdriver.Firefox() #Firefox
browser = webdriver.Chrome()  #Chrome
browser = webdriver.Ie()      #Internet Explorer
browser = webdriver.Edge()    #Edge

-- LiamBarrett - 24 Jun 2020
Topic attachments
I Attachment Action Size Date Who Comment
webdrivers_01_folder.pngpng webdrivers_01_folder.png manage 9 K 25 Jun 2020 - 15:56 UnknownUser  
webdrivers_02_start_menu.pngpng webdrivers_02_start_menu.png manage 113 K 25 Jun 2020 - 15:56 UnknownUser  
webdrivers_03_start_search.pngpng webdrivers_03_start_search.png manage 119 K 25 Jun 2020 - 15:57 UnknownUser  
webdrivers_04_properties_edit.pngpng webdrivers_04_properties_edit.png manage 49 K 25 Jun 2020 - 15:57 UnknownUser  
webdrivers_05_copy_path.pngpng webdrivers_05_copy_path.png manage 13 K 25 Jun 2020 - 15:59 UnknownUser  
webdrivers_06_new_path.pngpng webdrivers_06_new_path.png manage 19 K 25 Jun 2020 - 15:59 UnknownUser  
webdrivers_07_cmd.pngpng webdrivers_07_cmd.png manage 117 K 25 Jun 2020 - 16:20 UnknownUser  
webdrivers_08_install_selenium.pngpng webdrivers_08_install_selenium.png manage 11 K 25 Jun 2020 - 16:21 UnknownUser  
webdrivers_09_edge_driver.pngpng webdrivers_09_edge_driver.png manage 93 K 25 Jun 2020 - 16:58 UnknownUser  
webdrivers_10_cmd_admin.pngpng webdrivers_10_cmd_admin.png manage 38 K 25 Jun 2020 - 16:59 UnknownUser  
webdrivers_11_enable_edge.pngpng webdrivers_11_enable_edge.png manage 19 K 25 Jun 2020 - 17:00 UnknownUser  
Topic revision: r2 - 25 Jun 2020, LiamBarrett
© 2020 Ultranauts - 75 Broad Street, 2nd Floor, Suite 206, New York, NY 10004 - info@ultranauts.co