Automation – Make the machine do the work

As information technologies evolve in a rapid pace, human race has always been trying to find the best use of computers, from complicated mathematical calculation to deep machine learning. One of the most common uses amongst those is automation. By manipulating the machine with programs using codes and scripts, humans can describe any repetitive tasks in a form for a machine to understand. This makes it possible for a machine to execute the tasks without any human’s need for supervision. In software development, automation comes in handy in product testing and deployment phase. In fact, humans can effectively replace the boring manual testing with automation testing, reduce time consumption and increase the product quality.

Authors: Quan Dao and Sariseelia Sore

Automation testing and its benefits

Manual testing refers to the concept of performing test cases using human interaction (Itkonen & al. 2009, 494). Traditionally, manual testing is accounted for a great part of the quality assurance process. However, it is noticeable that automation testing is slowly replacing manual testing, due to its ability of cross-browser testing with deep penetration based on the predefined test suite. By utilizing machine or software in automation testing, developers can execute a certain amount of test cases based on the test script written in a particular programming language without human obstruction. Later on, the results are compared with the expected outcome. (Dustin et al. 2009, 4.) Compared to the manual testing where the cost of time, money and effort remain a tremendous burden, automation testing appears to be a better solution for regression and time efficiency. (Nguyen et al. 2006, 28.)

 It is a good practice to evaluate and plan the testing method before any development. This can prevent big errors in further stage of the development as well as preserve time and resources. Test automation is a promising candidate when it comes to regression testing (re-test the preexisted product and functions that are being changed or developed). Regression testing helps to ensure that the newly introduced changes work with the old program version. Furthermore, any repetitive tests, which are not likely to change throughout the development, sprint or cycle, should also be optimized to be automated. Generally, these tests are high data-driven, which means that the same function can be entered with large different data or input. Those data can be imported from a database to the test case to run in a different environment. (Fernandes & Fonzo 2018.)

 How to control the website interface in automation testing?

Selenium is an open source software testing framework developed in 2004 by Jason Huggins under Apache 2.0 (Selenium 2018). It serves for the purpose of mimicking the end-users’ interaction with a web application by controlling a browser’s web driver. Selenium supports almost every popular web browser nowadays, and the test suite can be written with many languages (Selenium 2018).

Selenium WebDriver is the most popular tool in test automation for web applications. Figure 1 indicates that Selenium WebDriver enables developers to compile and run an end-to-end test suite with its API. Based on different test cases, the tool passes the Selenese test script to the Selenium Core and controls the browser without the need to connect to a remote server unless it is not the native machine (Avasarala 2014, 13).

Figure 1. Interaction of WebDriver (Avasarala 2014, 13)

Each individual element on the web page can be located using UI locators that include various techniques to locate the desired elements on the webpage for the machine to interact with. After being queried, the elements can be manipulated with different methods, such as: clicking on the elements, moving the cursor, typing and input in textbox, etc.  (Selenium 2018.)

The stack requirements for installing Selenium WebDriver using Java programming language are listed in the Table 1. These components are critical in order to run and perform any automation tasks on browsers.

Table 1. Components requirement

An example: Signing up unlimited Facebook Accounts on Chrome browser

Figure 2 below displays the content of a java page that the author has created to sign up new accounts for Facebook using automation. The aim of this task is to open Chrome browser, get to Facebook page and sign up new accounts using random emails that are generated with random numerical suffix. At the beginning, the machine will import necessary components to run the script, for example ChromeDriver, junit, and Selenium WebDriver.

The script should be chosen to be run with junit as junit is defined to be the test runner. Junit executes the script starting from the @Test anchor. In the figure 2, each line of code ends with comments explaining the purpose of the step.

Figure 2. Script to automate Facebook account signing-up

This example shows how developers can automate the signing up process on webpages with programming. As there is no assertions to evaluate the outcome to any expected results, this is not considered testing. However, for further development with automation testing, developers can add assertions to assess whether or not the outcome is desired. For instance, the value of the textbox can be stored and compared to certain input value to decide if it meets the requirements. In fact, the machine can check if the button is clicked and if any further notifications follows. These practices are possible because they are happening on the webpage itself, and the Selenium WebDriver can detect and interact with them.

The Figure 3 illustrates clearly that the driver is controlling the browser with the notification “Chrome is being controlled by automated test software”. In this example, the driver enters all the needed information on the sign-up form, and then clicks on the submit button. Additionally, all text fields can be parsed as parameters, or the data may be imported from a database. This example test script can be run as many times as required with different, randomly generated email address every time. With this implementation, unlimited number of Facebook accounts can be created by running a simple script. It took approximately 10 seconds for the script to sign up for one account. Whereas, for a human, to sign-up for Facebook, a normal process will take up to several minutes. Moreover, the result is at maximum accuracy compared to human results with repetitive tasks.

Figure 3. Facebook sign-up automated page

Prevent your website from malicious automation attack

It does not require much to set up and run an automation task on a web browser. That is why it is necessary for any website to have some protection method against potential automation attack. Using captcha for verifying humans and computers apart is by far the most effective technique for protecting a site against automation (Robert 2018). Captcha generates elements on the site with non-static ID, which makes it impossible for the pre-determined script to locate, thus get access to.

Conclusion

For automation, it is imperative to ensure the reliability of the scripts, and frequent maintenance to keep track with changes of the automated object. Website automation tasks depend heavily on the web elements, and sometimes they are slightly changed on different web browsers and web resolutions, which results in the failure of the test case or automation task.

Overall, automation has been widely adopted, and implemented in every aspect of technology. The resources and time to set up an automation system may be demanding at first, however, in the long term, the effectiveness of the result is significant. For example, by running an automation test suite for a web application in a start-up company, the development team can witness a 71.46% of time reduction compared to manual testing of all the required functionalities. In fact, the number is only concluded within a two-month development timeframe. The use of automation testing will most likely appear even more efficient with time. (Dao 2018, 52.)

References

Avasarala, S. 2014. Selenium WebDriver Practical Guide. Birmingham B3 2PB, UK: Packt Publishing.

Dao, Q. 2018. Implementing test automation with Selenium WebDriver. Case study: MeetingPackage.com. Bachelor’s thesis. Lahti University of Applied Sciences, Faculty of Business and Hospitality Management. Lahti.  [Cited 1 Nov 2018]. Available at: http://urn.fi/URN:NBN:fi:amk-2018110116522

Dustin, E., Garrett, T. & Gauf, B. 2009. Implementing Automated Software Testing: How to Save Time and Lower Costs While Raising Quality. New York: Pearson Education Inc.

Fernandes, J. & Fonzo, A.D. 2018. When to Automate your Testing (and when not to). Oracle. [Cited 1 Oct 2018]. Available at: http://www.oracle.com/technetwork/cn/articles/when-to-automate-testing-1-130330.pdf

Itkonen, J., Mäntylä, M.V. & Lassenius, C. 2009. How do testers do it? An exploratory study on manual testing practices. In: 2009 3rd International Symposium on Empirical Software Engineering and Measurement. Lake Buena Vista, FL, USA. 15-16 Oct. 2009. 494-497. [Cited 1 Nov 2018]. Available at: https://doi.org/10.1109/ESEM.2009.5314240

Nguyen, H.Q., Hackett, M. & Whitlock, B.K. 2006. Global Software Test Automation: A Discussion of Software Testing for Executives. Cuperrtino: Happy About.

Robert, E. 2018. 9 Recommendations to Prevent Bad Bots on Your Website. [Cited 2 Nov 2018]. Available at: https://resources.distilnetworks.com/all-blog-posts/9-recommendations-to-prevent-bad-bots-on-your-website

Selenium. 2018. SeleniumHQ. Browser automation. [Cited 2 Oct 2018]. Available at: https://www.seleniumhq.org/

Authors

Quan Dao is a recent graduate at Lahti University of Applied Sciences, major in Business Information Technology. He finds joy in ensuring the quality of the product in the development process, with an aim to optimize the development and operation pipeline. He is interested in new opportunities, preferably in Quality Assurance and DevOps.

Sariseelia Sore works as Senior Lecturer in Business Information Technology Degree Programme at Lahti University of Applied Sciences, Faculty of Business and Hospitality Management.

Illustration: https://unsplash.com/photos/OqtafYT5kTw (Ilya Pavlov/CC0)

Published 11.12.2018

Reference to this publication

Dao, Q. & Sore. S. 2018. Automation – Make the machine do the work. LAMK Pro. [Cited and date of citation]. Available at: http://www.lamkpub.fi/2018/12/11/automation-make-the-machine-do-the-work/

Vastaa

Sähköpostiosoitettasi ei julkaista. Pakolliset kentät on merkitty *