December 28th, 2018

Download and Install Selenium Webdriver & Get Started with Test Automation

Software Testing

Are you afraid that you won’t be able to learn or do automation? It is the fear that most of the people have in their mind when they think of learning Automation tools and techniques. Due to a lack of guidance, they resist moving towards automation testing. I myself had this thought in mind before practically trying it. So, this article is to give you a quick start of automation using Selenium Webdriver.

Components of Selenium

There are four components of Selenium

  1. Selenium Integrated Development Environment (IDE)
  2. Selenium Remote Control (RC)
  3. WebDriver
  4. Selenium Grid

from which we’ll be using selenium Web driver.

Steps to Install Selenium WebDriver

  1. Download and install Python from the following link “https://www.python.org/, from “Downloads” tab click on “Python for windows”
  2. Download and Install PyCharm IDE for Python Developers from the link “https://www.jetbrains.com/pycharm/download/#section=windows”.

Configure PyCharm with WebDriver

  1. Open PyCharm.
  2. Go to “File” menu  > New Project > Select “Pure Python” > Click “Create” > Select “This Window
  3. Go to “File” menu  > Click on “Settings” > Click on “Project: Your Project name” > Click on “Project Interpreter

    Test Automation

  4. Click on “+” sign on the right side of the window > Type “Selenium” in the search field > Click on “Selenium” option  > Click on “Install Package”.
  5. The Package will be installed successfully.

Test Automation

Installing Gecko Driver

Gecko is a web browser engine used in many applications developed by Mozilla Foundation and the Mozilla Corporation. Gecko Driver is the link between your tests in Selenium and the Firefox browser. Gecko Driver is an executable file that you need to have in one of the system paths before starting your tests. To install Gecko follow the following steps:

  1. Go to https://github.com/mozilla/geckodriver/releases > Select the Gecko version according to your OS > Download it and extract it > You will get the “geckodriver.exe” file.
  2. Copy it and paste it in the folder where your python projects are being created.

First WebDriver Code

Below is an example of test case that will check that www.google.com opens and searches anything that user types Successfully.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys


driver = webdriver.Firefox()
driver.get(“https://google.com”)
assert “Google” in driver.title
elem = driver.find_element_by_name(“q”)
elem.clear()
elem.send_keys(“pycon”)
elem.send_keys(Keys.RETURN)
assert “No results found.” not in driver.page_source
driver.close()

Running the Test Case

To run the test case, Right Click on Test Case > Click on “Run ‘Your File Name’”.

Output:

Test automation selenium webdriver

Related Articles