What is Automation Testing?
Automation testing is a Software testing technique to test and compare the actual outcome with the expected outcome. This can be achieved by writing test scripts or using any automation testing tool. Test automation is used to automate repetitive tasks and other testing tasks which are difficult to perform manually.
Automation testing can be defined as a way to run a set of tests over and over again without having to execute them manually. Introducing automation tests in your test strategy is a way to save money and time.
Automation Based on the Type of Tests
Unit Tests: Unit Tests are the tests that are built to test the code of an application and are usually built into the code itself. They target coding standards like how the methods and functions are written.
These tests are more often written by the developers themselves, however, in today’s world, automation testers may also be asked to write them.
Executing these tests and getting no bugs from them will mean that your code will compile and run without any code issues. These tests usually do not target the functional aspects of the application and as they target code, it is more appropriate to automate them so that they can be run as and when required by the developer.
Integration Tests: Integration test as the name itself suggests means testing the application by integrating all the modules and checking the functionality of the application.
Integration testing can be done through API testing or can be done through the UI layer of the application.
Regression Tests: One of the most commonly automated test suites is the regression test suite. Regression, as you may already know, is the test that is done at the end of testing a new module to ensure that none of the existing modules have been affected by it.
It is repeated after each new iteration of testing and the main test cases stay fixed h usually a few new additions after a new iteration. As it is frequently run almost all the test teams try to automate this pack.
Some commonly used automation frameworks include:
- Linear (Record and playback)
- Keyword Driven
- Keyword Driven
- Data Driven
- Page Object Model
- Modularity Framework: We are using this
- The objects are defined once and reusable in all test methods.
- Small and to-the-point methods are created for individual functionalities
- The test case is the collection of these small methods and reusable objects
- This allows us to write maintainable code.
Automation Tools which we are using
Based on the type of testing you are targeting and the type of framework that you may want to build around it, the following tools are available to use:
Selenium: Very powerful tool for testing Web Applications. Provides multiple browser support.
The application which should be automated must have these factors:
- The application should not be in the early stages of its development. (The application should have all or some modules which are stable and tested by manual testers)
- The UI of the application must be stable. (The UI must not change frequently)
- The manual test cases of this application should be in written form.
Benefits of Automation Testing
- 70% faster than the manual testing
- Wider test coverage of application features
- Reliable in results
- Ensure Consistency
- Saves Time and Cost
- Improves accuracy
- Human Intervention is not required while execution
- Increases Efficiency
- Better speed in executing tests
- Reusable test scripts
- Test Frequently and thoroughly
- More cycle of execution can be achieved through automation
- Early time to market
What is Selenium?
Selenium is a free (open source) automated testing suite for web applications across different browsers and platforms. It is quite similar to HP Quick Test Pro (QTP now UFT) only that Selenium focuses on automating web-based applications. Testing done using a Selenium tool is usually referred to as Selenium Testing.
Selenium is not just a single tool but a suite of software, each catering to different testing needs of an organization. It has four components.
- Selenium Integrated Development Environment (IDE)
- Selenium Remote Control (RC)
- WebDriver (Using this)
- Selenium Grid
Brief Introduction WebDriver
The supported languages are…
- Note on Browser and Environment Support
- Internet Explorer versions 6 to 11, both 32 and 64-bit
- Microsoft Edge version 42.10240 & above ( partial support some functionalities under development)
- Firefox 39.0 and above
- Google Chrome 44.0. and above
- Edge Beta version 79 & Above
Operating System: All operating systems where the browsers above can run.
Download & Install Visual Studio
Step 1 – Install Microsoft visual studio 2017 & above
Step 2 – Downloaded VS_Community exe installed & open that exe
Open below the screen so select ASP.NET checkbox is select
Step 3 – Click on individual components >> Select all the highlighted checkbox if not selected by default. after a click on the Installed button (modify button when already installed VS)
Step 4 – Installed Visual Studio successfully.
Open VS and created automation testing project and installed packages process:
Step 5 – Select project
Step 6 – Select test and unit test project and click on Ok button (If you want so changed the name)
Step – 7 Created project looks like below
Step 8 – Right-click on Reference then manage Nugget packages
Step 9 – Basic Browse package required
contains the ChromeDriver class needed to instantiate a CHrome-specific driver onto the browser instantiated by the WebDriver class
contains the WebDriver class needed to instantiate a new browser loaded with a specific driver
Wait for load element
Below is sample code to launch Browser and validate Title of the page
Two way to run above code
- Right click on the TestMethod1 in the Test Explorer then click on Run
- Right click on code window & then click on Run Test(s)
Sample code output window (When click on Open additional output link below)