Selenium is an automation tool which is composed of multiple software tools like selenium IDE, web-driver, Selenium RC, Selenium grid.
Key features of Selenium includes:
1. Multiple browser support:Firefox, Chrome, Safari, Opera, Yes
2. Multiple OS support:Windows, OS X, Linux, Android and IOS
3. Multiple language support:Python, Ruby, Java
4. Free as in beer and freedom
Selenium supports different languages, here I would like to show you how to implement Selenium Web-driver with Python (Python 2.7).
It is a package management tool used to install and manage software package, written in Python.
It provides an isolated working environment which allow us to work on a specific project without worrying about affecting other projects.
In Order to install it simply do,
|1||pip install virtualenv|
Other python packages
There are other python packages. These are also need to be installed
In order to install this packages use the code
1.pip install selenium==2.40
2.pip install nose
We can use any OS, programming language and browser. Here I would like to show you how to implement Selenium Webdriver with Python.
- OS:Windows 8
- Python: python 2.7
- Browser: Firefox 28
- Selenium: Selenium 2.40
Writing a test
Automation testing performs the same functionalities as manual testing. But this is done with computer which allow you to do other works as well as easily repeat your tests. Test code runs a series of instruction to interact with web browser.
Write a sample test
For the cause, I am using a website http://demo.mahara.org using firefox. Make sure that title is “Home mahara” and also we can easily login using the respective credentials. Type the following code in the python shell and run it .
2.from selenium import webdriver
3.from selenium.webdriver.common.keys import Keys
#define a driver instance.for example firefox
7. def test_login_in_demo_mahara_org(self):
#navigate to the demo website
9. driver.get(“ http://demo.mahara.org//”)
#do assertion on the site title
10. self.assertIn(“Home-Mahara”, driver.title)
#define username web element
#enter username as student1
#enter password as testing1
#define login button
#click on the login button
#verify that logout button displays
17. self.assertTrue(driver.find_element_by_link_text(“Logout”),”Logout link”)
I hope this blog gives you a good insight about implementing Selenium Webdriver with Python. Feel free to contact for any queries.