August 19, 2014
Automating menial Browser activity using Selenium
Author: tec at 8/19/2014 10:25:00 pmToday I stumbled across a marvelous Framework called Selenium which does browser automation. It lets you programmatically control a web browser session which can be used for automating tests or controlling browser to perform menial works.
Here's a small snippet that I put together for myself just to try out selenium's python bindings. Yes, python is the language of my choice currently! :) Selenium binds of various languages are available on their official website at : http://www.seleniumhq.org/
What this script does is open a third party website: way2sms.com, log me in using my username, password and then send a message to any number of my choice. All of this is done programmatically! So all I've to do is fire up a console and enter my username, password, a mobile number and a message and selenium will handle the rest. Of course, this is just an example and one can use this to perform a variety of tasks, boring or otherwise.
You can install selenium python binding using:
sudo easy_install selenium
Since I hacked this together in hurry, it doesn't include any comments but the code should be self explanatory and easy to follow because all it does is find a web element (like an input box or a button) and send it a sequence of keys ( string value of action keys like RETURN ).