Selenium Python bindings are pretty easy to install, since Ubuntu 14.04 LTS and other Ubuntu versions comes pre-installed with python.
Ubuntu 14.04 and higher versions comes with Python 2.7x and higher pre-installed.
One issue which might come in the way is that Python 2.7.x is the version that comes per-installed with Ubuntu 14.04. As of now we have a release of Python 3.x, so if you use Python3 command to run Selenium scripts, you will not be successful.
My suggestion is to use Python 3, because this is the latest version of Python, which will have the latest updates and methods.
So first of all let us start with installing Python 3 on the system.
Installing Python/ Using Python 3
Open your command line and run the following command
$ sudo apt-get install python3
Let the installation process through. Once the installation is complete, you can invoke python 3 shell using
python3
This will allow you to run Selenium with Python 3. However, if you simply run your python script with the command python scriptname.py
, it will still use Python 2.
To remove this, you need to set the system to use Python 3 as an alias for python
command.
Open your command prompt (using Ctrl + Alt +T ). Open your ~/.profile
or ~/.bashrc
using gedit
Add new alias to change your default python executable as
alias python = python3
Save the file and check the corresponding python version. This time you’ll see that you get a python3 version returned in command prompt.
Installing Selenium
You probably won’t find any other easy installation. Installing Selenium python bindings on a Ubuntu system is as easy as running a single command. The command you need to run is
pip install -U Selenium
Yeah. That’s all you need to do. Let the installation process through and you should be good to use Selenium.
Alternatively, you can also install Selenium without using Selenium package source from http://pypi.python.org/pypi/selenium
. Download Selenium package from the above source and run this command
python setup.py install
You can choose any one of the two methods, but I would suggest go for the first one, because it is a lot easier than the second, although the second one isn’t tough either.