How to Speed Up Your Automation Testing

How to create test automation faster.

Well, for creating test automation, people generally use one of the two approaches. The first approach is Record and Run, in which the steps of a manual test case are recorded, using the tool and also the verification points given as per the Expected Results are also added. And that creates the script. The second approach that people follow is to create a script using something called as a scripting or descriptive programming, in which they have to write the Steps and Expected Results in a scripting language or a programming language. Now, each approach comes with its own problems.

Now, for instance, Record and Run has certain advantages and also has certain disadvantages. First of all, the Record and Run are easy. Even people who do not know scripting or programming can use it. It is quick because it only takes as much time as needed to record the script and the Steps are self-explanatory. But, it has certain disadvantages. The input data and the output verification data is hard-coded. Record and Run scripts also tend to be fragile. Even if there is a very minor change in the application, the Record and Run script can fail. And modification requires re-recording. So the entire time has to be spent once again. The other approach that people follow is Scripting or Descriptive Programming. It also has it’s advantages and disadvantages. The advantages are that it is more robust than a pure Record and Run the script. We can parameterize the input and output test data. meaning that whatever inputs are to be given to the application, those can be put in an external data source. The script becomes easy to modify. But, the disadvantage is that it is difficult in the sense that it requires scripting or programming knowledge. It takes much more time to create than Record and Run the script. And it needs comments, in order to understand what exactly the script is doing. So, we can have a Hybrid approach, where we use both Record and Run approach and also Scripting or Descriptive Programming approach.

So, here in the Hybrid approach, we use a quick recording. Then, we export it to the script format. And then we enhance the script to make it robust and to add other features to the script, like data parameterization. An advantage of using the Hybrid approach is that it is quicker, faster than a pure Scripting or Descriptive Programming approach. We enjoy the advantage of being able to create a robust script. And we can use other things like input and output data parameterization. And of course, since it is a script, it is easy to modify. Now, let us see an example. This Hybrid approach is possible in tools which provide Record and Play feature, like Selenium, TestComplete and QTP(UFT). So, here I have Selenium IDE and I use Selenium IDE to record a script. Now, I am running the script. And this script just opens the Wikipedia page. Then, it searches for a term, “software”. And then, it presses the Enter key by searching the “software”. Now, this exact same script I exported to Selenium WebDriver and I made certain modifications. As you can see, I have parameterized the script. Instead of having the data hard-coded in the script, the data is being read from this file. So, it converts the file into the input test data. So, we have “software”, “test” and “automation” given in the file. And also, we have exception handling, by basically using a try-catch block in the script.

Now, if we run this script. So, it takes all those search terms one-by-one on the Wikipedia site and searches them one-by-one. So, this is the Hybrid approach. Using the Hybrid approach, I was able to get almost 80% of the test automation code. I just had to add the remaining 20% code myself. Overall, it reduced my scripting time by 80% So, if earlier, I had to spend 10 minutes in order to write my test automation, now, I can do the same thing in only 2 minutes. So, that is the Hybrid approach and we can use it to make our test automation faster.