- Before You Start
- Introduction to Selenium
- Setup Eclipse
- Browser and Navigation Commands
- Element Identification
- Tables, Checkboxes and Radio Buttons
- Selenium Waits, Alerts and Switch Windows
- Action Class
- TestNG Framework
- Introduction to Selenium
- Database Connections
- Data Driven Automation Framework
- JUnit Java Framework
- Page Object Model (POM)
What is Automation Testing?
Automation Testing uses an automation software to execute test case suite. The automation software enters test data into the system under test, compare expected and actual results and generate detailed test reports. Successive development cycles of the system will require execution of same test suite repeatedly. Using a test automation software, it’s possible to record this test suite and re-play it as required. Once the test suite is automated, no human intervention is required.
Automated software testing is important due to following reasons:
- Manual Testing of all workflows, all fields, all negative scenarios is time and money consuming
- It is difficult to test for multilingual sites manually
- Automation does not require Human intervention
- Automation increases the speed of test execution
- Automation helps increase Test Coverage
There are several situations, which cannot be tested manually and require automation testing such as,
- Comparing two images pixel by pixel.
- Comparing two spreadsheets containing thousands of rows and columns.
- Testing an application under the load of 100,000 users.
- Performance Benchmarks.
- Testing the application on different browsers and on different operating systems in parallel.
Use of Automation Testing
The goal of Automation is to reduce the number of test cases to be run manually and not to eliminate Manual testing altogether. The benefits of automated testing are:
- 70% faster than the manual testing
- Increase in test coverage of application features
- Reliable in results
- Ensure Consistency
- Saves Time and Money
- Improves test accuracy
- Human Intervention is not required while execution
- Increases Efficiency
- Complex testing made easy
- Better speed in executing tests
- Re-usable test scripts
- Test Frequently and thoroughly
- More cycle of execution can be achieved through automation
Tools for Automation Testing
Automated software testing is becoming more and more important for many software projects in order to automatically verify key functionality, test for regressions and help teams run a large number of tests in a short period of time. There are various tools that help software teams build and execute automated tests. Many teams are actively using unit tests as part of their development efforts to verify critical parts of their projects such as libraries, models and methods.
With the growing number of web-based applications this is changing, however, as verifying and testing web-based interfaces is easier and there are various tools that help with this, including open source tools. Below are few of the widely used automation testing tools:
Selenium is a software testing tool used for Regression Testing. It is an open source testing tool that provides playback and recording facility for Regression Testing. The various features of selenium are:
- It provides the provision to export recorded script in other languages like Java, Ruby, RSpec, Python, C#, etc
- It can be used with frameworks like JUnit and TestNG
- It can execute multiple tests at a time
- Autocomplete for Selenium commands that are common
- Store tests as Ruby Script, HTML, and any other format
- It allows to insert comments in the middle of the script for better understanding and debugging
Quick Test Professional
Quick Test Professional (QTP) is widely used for functional and regression testing as it addresses every major software application and environment. To simplify test creation and maintenance, it uses the concept of keyword driven testing. It allows the tester to build test cases directly from the application. The various features of QTP are:
- It fix defects faster by thoroughly documenting and replicating defects for developer
- Collapse test creation and test documentation at a single site
- Parameterization is easy than WinRunner
- QTP supports .NET development environment
- It has better object identification mechanism
- It can enhance existing QTP scripts without “Application Under Test” being available, by using the ActiveScreen
Rational Functional Tester
Rational functional tester is an Object-Oriented automated Functional Testing tool that is capable of performing automated functional, regression, data-driven testing and GUI testing. The various features of Rational Functional Tester are:
- It supports a wide range of protocols and applications like Java, HTML, NET, Windows, SAP, Visual Basic, etc.
- It can record and replay the actions on demand
- It integrates well with source control management tools such as Rational Clear Case and Rational Team Concert integration
- It allows developers to create keyword associated script so that it can be re-used
- Eclipse Java Developer Toolkit editor facilitates the team to code test scripts in Java with Eclipse
- It supports custom controls through proxy SDK (Java/.Net)
- It supports version control to enable parallel development of test scripts and concurrent usage by geographically distributed team
Watir is an open source testing software for regression testing. It enables to write tests that are easy to read and maintain. Watir supports only internet explorer on windows while Watir webdriver supports Chrome, Firefox, IE, Opera. The various features of Watir are:
- It supports multiple browsers on different platforms
- It uses a fully-featured modern scripting language Ruby
- It supports web application regardless of its development platform.
Silk Test is designed for doing functional and regression testing. For e-business application, silk test is the leading functional testing product. It is a product of Segue Software takeover by Borland in 2006. It is an object-oriented language just like C++. It uses the concept of an object, classes, and inheritance. The various features of Skill test are:
- It consists of all the source script files
- It converts the script commands into GUI commands. On the same machine, commands can be run on a remote or host machine
- To identify the movement of the mouse along with keystrokes, Silktest can be executed. It can avail both playback and record method or descriptive programming methods to get the dialogs
- It identifies all controls and windows of the application under test as objects and determines all of the attributes and properties of each window
Why Automation is Important for Your Career?
Testing is an integral part of any successful software project. The type of testing (manual or automated) depends on various factors, including project requirements, budget, timeline, expertise, and suitability. Three vital factors of any project are of course time, cost, and quality. The goal of any successful project is to reduce the cost and time required to complete it successfully while maintaining quality output.
Many Organization have developed test automation frameworks based on the above mention test automation tools. Automation frameworks designed and developed in future will be more autonomous in future and would require minimal intervention by the testing professional. Implementing automated testing can be challenging initially but the key benefits you are going to gain make it very important for your career.
By implementing automated testing, it can help improve code quality and development velocity. When code changes are not causing errors, developers will have more time to focus on each sprint goal. For example: with automation testing, you can save time with data-driven testing.
Higher test coverage
Automated software testing can help you save time and increase test coverage. Lengthy tests are usually time-consuming and laborious to perform manually; this can be run with automated testing unattended on different computers with different configurations. Automated testing also provides testers more time and effort to focus on more futures, thus leading to a higher quality of the application.
For the manual testing, human errors are inevitable during repetitive and monotonous manual tests. When it is done with automated testing, it can help avoid the risks of human errors, increase accuracy and save time.
You can never get bored while conducting automation testing as the setting up test cases take a coding brain and thought, which keeps the best of your technical minds engrossed and dedicated to the process.
The results are public
In the cases of manual testing, the rest of the team involved is not able to see the results while the tests are being run. With automated tests, though, people can simply sign into the testing system and see the yielded results. This puts a good base for superior team cooperation and eventually a better final product.
What is Selenium?
Selenium is an open-source automated testing suite which has been designed for web applications spanning across different browsers and platforms. While being similar to Quick Test Pro (QTP), Selenium concentrates on automation of web-based applications. It is a collection of different tools, and it also has different developers as well.
Advantage of Selenium
Selenium is an open-source tool and support for the same exists for all the browsers that exist currently. It also supports popular programming languages such as Perl, Ruby, Java and .Net allowing the user to pick and choose the one that suits them the best. The look and feel of a web application is required to be tested across many web browsers to deliver user experience that is flawless and perfect. There are many test automation tools which are relied upon by testing professionals to test web applications most effectively. Such tools most often fail to test the application when changes and enhancements are made to the code on a frequent basis. Selenium makes it easier for testers to evaluate the respective web application without investing any extra time and effort.
The some major advantages of Selenium are as below:
- Use of one test script across multiple web browsers: Selenium permits testers to write the test script a single time and run the same on several web browsers.
- Option to choose programming language: In Selenium users can write test scripts using any programming language.
- Supports Multiple Testing Frameworks: Selenium being a web application testing tool, it can also be used as a GUI driving library. Therefore the users have the choice to use Selenium for wrapping test scripts in other test frameworks. Testers also have option to integrate Selenium while utilizing any framework of their choice.
- Smooth Integration with existing ecosystem: Selenium can be integrated with various tools that are widely used like QMetry and Hudson. Therefore, testers are able to integrate the testing tools with the existing solutions and suite of tools. The simple and easy integration process associated with Selenium does not need the users to additionally invest in commercial tools.
History of Selenium
Selenium Grid was developed by Patrick Lightbody to address the need of minimizing test execution times as much as possible. He initially called the system “Hosted QA.” It was capable of capturing browser screenshots during significant stages, and also of sending out Selenium commands to different machines simultaneously.
Shinya Kasatani of Japan created Selenium IDE, a Firefox extension that can automate the browser through a record-and-playback feature. He came up with this idea to further increase the speed in creating test cases. He donated Selenium IDE to the Selenium Project in 2006.
In 2008, the whole Selenium Team decided to merge WebDriver and Selenium RC to form a more powerful tool called Selenium 2, with WebDriver being the core. Currently, Selenium RC is still being developed but only in maintenance mode. Most of the Selenium Project’s efforts are now focused on Selenium 2.
Component of Selenium
Architecture of Remote Control
Selenium Remote Control (RC) is a test tool that allows to write automated web application UI tests in many programming language. As of version 2.25.0, RC can supports Java, C#, PHP, Python, Perl, Ruby. Selenium Remote Control is great for testing complex AJAX-based web applications. It can be used for any java script enabled browser.
Architecture of Remote Control
In RC server has to be restart again and again i.e. RC completely depends upon server. Switching between the multiple instances of the same browser is not possible. Switching between the multiple instances of the different browsers is not possible.
Architecture of WebDriver
The various features of Selenium WebDriver are:
- Open source
- Supports all the key vendors of the browser like Mozilla Firefox, Internet Explorer, Google Chrome, Safari, etc.
- Support Multiple languages like C#, JAVA, Ruby, Perl, Python, and PHP.
- Supports multiple platforms like Linux, Windows, MAC, etc.
- No middleman like Selenium RC server is required.
- Easy to remember API’s.
- Easy to integrate with Testing frameworks.
- Framework Development.
- Parallel Testing capabilities.
- The API’s written in WebDriver can directly interact with browsers.
The architecture of WebDriver is as below:
Architecture of GRID
Selenium Grid is a tool is the last component of the selenium suite and is used together with Selenium RC to run parallel tests across different machines and different browsers all at the same time. Parallel execution means running multiple tests at once. The various features of GRDI are:
- Enables simultaneous running of tests in multiple browsers and environments.
- Fast Execution and Saves time enormously by reduces the execution time as test cases are executed parallels.
- Platform Independent, support almost all Operating System
- Language Independent.
- Utilizes the hub-and-nodes concept. The hub acts as a central source of Selenium commands to each node connected to it.
In Grid one of the systems is created as Hub. Hub works as a central point controlling all the nodes. Nodes are an actual machine on which execution is done.
The architecture of GRID is as below:
Difference between API’s and GUI’s
There are many approaches to test automation. The general approaches used widely are:
- Graphical user interface testing. A testing framework that generates user interface events such as keystrokes and mouse clicks, and observes the changes that result in the user interface, to validate that the observable behavior of the program is correct. Many test automation tools provide record and playback features that allow users to interactively record user actions and replay them back any number of times, comparing actual results to those expected. The advantage of this approach is that it requires little or no software development. This approach can be applied to any application that has a graphical user interface. However, reliance on these features poses major reliability and maintainability problems. Relabeling a button or moving it to another part of the window may require the test to be re-recorded. Record and playback also often adds irrelevant activities or incorrectly records some activities.
- API driven testing. A testing framework that uses a programming interface to the application to validate the behavior under test. Typically API driven testing bypasses application user interface altogether. It can also be testing public (usually) interfaces to classes, modules or libraries are tested with a variety of input arguments to validate that the results that are returned are correct. API testing is widely used by software testers due to the difficulty of creating and maintaining GUI-based automation testing. It involves directly testing APIs as part of integration testing, to determine if they meet expectations for functionality, reliability, performance, and security. API testing is considered critical when an API serves as the primary interface to application logic since GUI tests can be difficult to maintain with the short release cycles and frequent changes commonly used with agile software development and DevOps.
- Automation Testing uses an automation software to execute test case suite
- Selenium is a software testing tool used for Regression Testing
- QuickTest Professional (QTP) is widely used for functional and regression testing as it addresses every major software application and environment
- Rational functional tester is an Object-Oriented automated Functional Testing tool that is capable of performing automated functional, regression, data-driven testing and GUI testing
- Watir is an open source testing software for regression testing
- Selenium Grid is a tool is the last component of the selenium suite and is used together with Selenium RC to run parallel tests across different machines and different browsers all at the same time