Test automation using selenium
- 2. Contents
Introduction to test Automation.
Drawbacks of Manual Testing
When does test Automation make sense?
Introduction to Selenium
Selenium Components
Introduction to TestNG Framework.
2
- 3. Test Automation
The process of converting the manual test
cases to test scripts by using any automation
tool is known as Automation.
3
- 4. Drawbacks of Manual Testing
Manual testing is not accurate at all times due to
human error, hence it is less reliable.
Manual testing is time-consuming, taking up
human resources.
Manual testing is only practical when the test
cases are run once or twice.
4
- 5. When Does Test Automation make sense?
When there are many repetitive tests
When there are frequent regression testing iterations
When you need to simulate large number of users who are using the application resources
When AUT is having comparatively stable UI
When you have large set of BVT cases
When you can’t rely on manual test execution for critical functionality
5
- 6. Test Automation Tools
Selenium (Open Source)
Quick Test Professional By HP
Silk Test By Borland
Watir
Sahi
6
- 7. Selenium
Selenium is one of the most popular automated testing suites.
Selenium is designed in a way to support and encourage automation testing of
functional aspects of web-based applications and a wide range of browsers
and platforms.
Due to its existence in the open source community, it has become one of the
most accepted tools amongst the testing professionals.
7
- 8. Why Selenium ?
It is free and open source.
Have cross browser compatibility (Firefox, chrome, Internet Explorer, Safari etc.
Have great platform compatibility (Windows, Mac OS, Linux etc.)
Supports multiple programming languages (Java, C#, Ruby, Python, Pearl etc.)
Saves time and money, manual effort.
We can maintain Accuracy by repeating the same task in same manner.
Have a large user base and helping communities
8
- 9. Limitation of Selenium
Selenium supports testing of only web based applications
Mobile applications cannot be tested using Selenium
Captcha and Bar code readers cannot be tested using Selenium
Reports can only be generated using third party tools like TestNG or Junit.
User is expected to possess prior programming language knowledge.
9
- 11. Selenium IDE
It is a Firefox plugin that you can install as easily as you can with other plugins. However,
because of its simplicity, Selenium IDE should only be used as a prototyping tool.
If you want to create more advanced test cases, you will need to use either Selenium RC
or WebDriver.
11
- 13. Limitations of Selenium IDE
Can run the test only on Firefox
No Programming login (like loops, conditional statements) can be applied
Selenium IDE can execute scripts created in Selenese only.
Selenese is the set of selenium commands which are used to test your web application.
Tester can test the broken links, existence of some object on the UI, Ajax functionality,
Alerts, window, list options and lot more using selenese.
It is difficult to use Selenium IDE for checking complex test cases involving dynamic
contents
13
- 14. Selenium RC
A solution to cross browser testing.
A server, written in Java and so available on all the platforms.
Acts as a proxy for web requests from them.
Client libraries for many popular languages.
Bundles Selenium Core and automatically loads into the browser
This is the first automated web testing tool that allowed users to use a programming language
they prefer.
Selenium RC has Built-In Test Result Generator
14
- 16. Selenium Webdriver
WebDriver is a tool for testing web applications across different browsers using different
programming languages.
WebDriver is faster than Selenium RC because of its simpler architecture.
WebDriver directly talks to the browser while Selenium RC needs the help of the RC
Server in order to do so.
WebDriver's API is more concise than Selenium RC's.
16
- 18. Setup Selenium
Java Development Kit
(JDK).http://www.oracle.com/technetwork/java/javase/downloads/index.html
Eclipse IDE - http://www.eclipse.org/downloads/
Java Client Driver - http://seleniumhq.org/download/
When starting a WebDriver project in Eclipse, do not forget to import the Java Client Driver files
onto your project
Each other browser has its own driver server.
18
- 19. Locating an Element
Locating elements in WebDriver is done by using the findElement() and findElements()
method.
The following are the available options for locating elements in WebDriver:
1. By.className
2. By.cssSelector
3. By.id
4. By.linkText
5. By.name
6. By.partialLinkText
7. By.tagName
8. By.xpath
19
- 20. Navigation Commands
WebDriver provides these useful navigation commands
navigate().forward()
navigate().back()
navigate().to()
navigate().refresh()
Close() is used to close a single window;
while quit() is used to close all windows associated to the parent window that the
WebDriver object was controlling.
20
- 21. More Commands
Waits In Selenium
1. Implicit Waits:
2. Explicit Waits:
Visibility Of Elements: web elements can be buttons, drop boxes, checkboxes, radio
buttons, labels etc.
1. isDisplayed()
2. isSelected()
3. isEnabled()
For Alerts and frames: use switchTo
21
- 22. Selenium Grid
It is Latest Selenium tool.
Selenium Grid can be used to execute same or different test scripts on multiple
platforms and browsers concurrently so as to achieve distributed test execution, testing
under different environments and saving execution time remarkably.
In Simple words it is used in parallel Executions of Programs.
22
- 23. TestNG Framework
TestNG is a testing framework inspired from JUnit and NUnit but introducing some new
functionality that make it more powerful and easier to use.
It is an open source automated testing framework . where NG of
TestNG means Next Generation.
23
- 24. Benefits of TestNG
There are number of benefits but from Selenium perspective, major advantages of TestNG are -
It gives the ability to produce HTML Reports of execution
Annotations made testers life easy
Test cases can be Grouped & Prioritized more easily
Parallel testing is possible
Generates Logs
Data Parameterization is possible
24