It looks like a daunting journey from Manual Testing to Automation Testing. The different languages, tool options, structure and technical jargon you're faced with can make it difficult to know where to start.
It doesn't have to be hard and scary. The steps to getting there are actually surprisingly simple.
- Understand the principles of Object Oriented Languages
- Choose a language and tools
- Learn how to interact with web pages
- Design a test suite structure
- Write tests
- Run tests and report
Looks a lot less scary as an achievable to-do list. Let’s look at each of these in a little more detail.
Understand the principles of Object Oriented Languages
This doesn't mean you have to be able to write an entire application in C# or Java. Most IDEs (integrated development environments) have built in code-completion, which is a bit like the autocomplete you get on phones. With a solid understanding of syntax and some knowledge of where you're going, the code will almost write itself.
Choose a Language and Tools
Generally, you will choose the language that your application is being developed in, so your framework can sit alongside application development.
The tools are influenced by the language you use and the project on which you’re working. Commonly, .NET houses have a tendency towards Visual studio and many Java places use Eclipse or IntelliJ. Once you know how to use one IDE you’ll easily pick up how to use others, similar to how different word processors have different looks and functionality, but ultimately you can write, edit and save documents.
Learn how to interact with web pages
Selenium with Webdriver is a tool that drives a browser. As a very basic model, think of the browser as a car, the Webdriver as a person driving, Selenium as a SatNav, and you are the person giving destinations to the SatNav. If you want to go to the homepage, you need to use Selenium to tell Webdriver to go to the homepage in the browser.
In order for the Webdriver to select a link, it needs you to tell it where that link is. You'll need to learn how to uniquely identify any element on a web page, with the most common methods being ID, XPath and CSS selectors. When you understand how these methods work, identifying elements is easy.
Design a test suite structure
In manual test scripts, you might have "Go to homepage URL:www.example.com" as a step used hundreds of times in all of your test cases. Good practice is to create that action separate to the test cases, and call it into the test cases that require it. That way if it changes you only need to update it in one place and it’s automatically pulled into all tests.
Exactly the same principle applies in Test Automation. The more steps you can pull out of the actual test, the more reliable and maintainable the tests become. In automation, the action is called a method. Methods are written completely separate to the tests, and then when the tests are executed they call the method. A very good model that implements this technique is the Page Object Model, taught on our courses.
When writing a manual test script, you have a set of steps with an expected outcome for each. These are grouped together to create a single test case that will pass or fail depending on the results of the steps. The same principles apply in Automation tests. You create a test method (test case), in this test method you execute a set of page object methods (actions), and you use assertions to check all is as it should be (expected results).
Writing the tests might sound like the hardest bit, but once you have the understanding of how it all works and how to do it, it's actually the easy bit!
Run tests and report
Automation tests are usually used in one of two ways:
- As part of BDD where you link the tests to your requirements.
The tests are run as part of continuous integration and deployment, and the results report is a BDD level (requirements coverage) report.
- As part of a regression test suite.
Test are usually executed as part of continuous integration and deployment. Tests are expected to pass, and reports are simple. Tools/plugins exist to generate project facing reports if required.
Many people that want to get into test automation jump straight in to learning how to code. Although understanding how to code is important, it’s far from the only aspect, and as with spoken languages, it’s much easier to learn through use.
More important is learning how to set up your framework, and how the structure and relationships in the Automation Test suite works. Once you understand all of that, coding the tests is easy.