Ever since its inception around early 90’s, Python has been one of the most popular languages. It supports a number of platforms and gives importance to readability by using white spaces instead of using braces, which is used by other languages like Java and C# to represent code. The reference implementation of the language is managed by CPython (an open source tool).

If you have a basic idea about the working of WebDriver, you will see and understand how WebDriver can be used in various editors and languages.


The following components are required to create and run the WebDriver test in Python.

  • Python
  • WebDriver
  • Gecko driver proxy for Firefox
  • An editor

In order to get Python, you can use OSx Sierra, which comes with already installed Python 2.7. Else, you can simply install a new version of Python to write WebDriver. You can also install a Python environment manager pyenv from a terminal prompt using the following command.

brew install pyenv

You can install WebDriver from the same terminal using the Python’s package manager, pip.

pip install webdriver

In order to communicate with the actual browser, you need to add the Firefox driver proxy. You need to get the appropriate proxy.  Firefox’s driver is part of the releases of Mozilla’s Gecko Driver. So, you must download the driver according to the version of Windows (x32/x64). The drivers are available in zip format. Extract the zip file to a location and add the location to the system’s PATH environment variable.


Python’s code is stored in a text file format, like Java, C#, and other languages. There are a number of editors available for OSx that can be used to create and edit .py files. Some of the most common editors include Vim, TextMate, Sublime, etc.

Writing and Running a Simple Test

Creating a test in Python is very simple. However, the mechanism depends on the editor you are using.

For example, if you have created your test by the name webdriver_basics.py, you can run the test using the following command from the same directory where you have created the file.

python webdriver_basics.py

You may also like: Independent Software Testing and Its Benefits

Leave a comment

Your email address will not be published. Required fields are marked *