How to use Selenium Web Driver in Python | Ubuntu 14.04

Following are the step by step commands for making sure the right way in which you are preceding for making automation scripts for web browsers with selenium.

Selenium :

Selenium automates browsers. That’s it! What you do with that power is entirely up to you. Primarily, it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) also be automated as well.

Selenium has the support of some of the largest browser vendors who have taken (or are taking) steps to make Selenium a native part of their browser. It is also the core technology in countless other browser automation tools, APIs and frameworks.

 

Make sure you have latest browser bundle. I prefer chrome.

Step 1: Download and install Google chrome for your Linux distribution.

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

sudo dpkg -i --force-depends google-chrome-stable_current_amd64.deb

Step 2: For selenium to work you should have chrome driver. Make sure you download latest driver and put it in following directories after uncompressing.

LATEST=$(wget -q -O - http://chromedriver.storage.googleapis.com/LATEST_RELEASE)

wget http://chromedriver.storage.googleapis.com/$LATEST/chromedriver_linux64.zip

3: Create symlinks

unzip chromedriver_linux64.zip 
sudo ln -s $PWD/chromedriver /usr/local/bin/chromedriver

 

4: Install Selenium with pip

apt-get install python-pip
pip install selenium

5: Sample Python program . for reference visit http://www.seleniumhq.org/docs/03_webdriver.jsp

$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> from selenium import webdriver
>>> d = webdriver.Chrome()
>>> d.get("http://www.google.com/")
>>> d.title
u'Google'

 

 

Follow our Youtube Channel for tutorials on Ethical Hacking

Click here to visit our channel –> CHANNEL

#like #comment #share

Click here to visit our Facebook Page SECTOR443

Thankyou

Regards

Stay Safe Stay Secure | Sector443

#sector443.com

Leave a Reply

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