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 like Selenium!. Test automation is used to make testing process faster and check other testing tasks which are difficult to perform manually.
Why use automation testing?
Because we are human we have limited amount of energy and attention to focus on repetitive tasks so we make mistakes. It's almost impossible not to miss a single test in million of functionality of a software.
But we still want to use manual testing because computers does not have good judgement like humans. automated test scripts don’t pick up visual, audio and human senses issues.
Human testers can quickly identify when something looks “off” when a tester interacts with software as a user would, they’re able to discover usability issues and user interface glitches. Automated test scripts can’t test for these things.
Not everything that can be done with automation, But it would be great if you can automate those repetitive boring tasks or tests.
What is Selenium?
Selenium automate web applications across different browsers and platforms. That's it!
Selenium is great, and it can be integrated with many different languages, and today I will show you how to do it with JavaScript. This is an ongoing project, and I plan to update more examples or test cases in the future blogs.
What is Mocha?
Mocha is a testing library for Node.js, created to be a simple, extensible, and fast testing suite. It's number one chosen testing framework by developers.
- Installation
You need to install either Yarn or Node on your machine. In this project, I will use Node for installing packages and running scripts.
First, we need to start a project
yarn init or npm init
Then install dependencies
npm add chromedriver selenium-webdriver
npm add mocha -D
- Getting started
After that, we can start writing our test cases
- Run The Test Case
Whenever you want to run the test, just use this command:
npm run test
The below result shows that the test has been successfully completed.
vizushu$ npm run test
npm run v1.9.4
$ mocha --recursive --timeout 10000 test.js
Checkout Google.com
✓ Search on Google (2058ms)
1 passing (3s)
Done in 3.79s.
That's all you need to start with your automation testing! I will continue with more test cases next blog and how to get the selectors likes xpath(), Css() for your automation testing!
Top comments (1)
When using Selenium WebDriver with JavaScript, it is important to follow best practices in order to get the most out of the tool and avoid common pitfalls, check how much basics of javascript is required for selenium automation tester