Artificial Intelligence in Test Automation
By Sakshi Pandey, Community Contributor - September 14, 2022
Artificial intelligence is a field that, in its most basic form, combines computer science and substantial datasets to facilitate problem-solving. There are three primary divisions of AI:
- ANI (Artificial Narrow Intelligence) – This falls under weak AI, and is a type of AI trained to perform specific tasks. Most AI we see today is ANI since it has a narrow focus to solve a specific problem.
- AGI (Artificial General Intelligence) – This falls under strong AI and is a form of AI that remains theoretical. AGI has not yet been achieved but it is projected to be a machine that would have problem solving, learning, and other intelligent traits equivalent to a human being.
- ASI (Artificial Super Intelligence) – We have only been able to get glimpses of what such an AI may look like in sci-fi movies. ASI is another, as of now, theoretical AI. This is a form of AI that would supersede human ability and intelligence.
Also Read: How AI can change Software Testing?
The difference between AI, ML, and DL
Although Artificial Intelligence, Machine Learning, and Deep Learning are all terms used interchangeably in most content, they are in fact nuanced and different from one another. As illustrated above, machine learning and deep learning are actually subsets of artificial intelligence; With deep learning being a sub-field of machine learning.
So what differentiates these fields?
|Artificial Intelligence||Machine Learning||Deep Learning|
|Ability of a machine to develop its own intelligence.||Ability of a machine to use algorithms by which it can automatically learn from data and experience.||Ability of a machine to learn via algorithms which mimic the human brain.|
The simplest definition of the outermost layer, as discussed earlier, is the ability of a machine to use datasets to facilitate intelligent problem solving. The second layer, machine learning, is a subset of artificial intelligence and at its core it uses algorithms to automatically learn from data and gain experience to solve a particular problem. The goal of AI is to build intelligent machines that can carry out tasks that would typically need human intelligence. Machine learning came into being as a subset of AI when people realized that teaching computers to learn to address and carry out tasks from datasets provided to them is more productive than rigidly programming them to execute specific actions.
The innermost layer, deep learning, is a layer which attempts to mimic the human brain using a concept called neural networks. One can think of these as being akin to the neurons present in the human brain. When these networks have more than three layers the algorithm can be classified to be deep learning. Deep learning differs from machine learning in how it learns. Non-deep machine learning is reliant on human guidance to learn; The deep learning algorithms however are scalable and require far less human intervention.
AI in Automation Testing
Artificial intelligence, Machine Learning, and Deep Learning are the trend of the moment. With everyone chomping at the bit to get the jump on their competitors by employing AI, it’s no surprise that software testing companies are also getting in on the trend.
General Applications of AI for Intelligent Test Automation:
- Self-healing tests: Traditional test automation tools have certain identifiers to define the components of an application. When the application is updated or changed in any way these components can also change. Due to the fixed definitions given to these elements, the tests which were functioning fine prior to the change, will now fail and provide a false negative result. Self-healing tests apply artificial intelligence algorithms to automatically identify unexpected errors due to dynamic properties and recommend a better alternative, or automatically update the script. This kind of testing not only stops tests from failing, but it also saves the time which a QA might have had to spend trying to find and fix the issue.
- Visual Locators: In AI-based user interface testing, visual locators are now able to find elements, even when their locators have been altered, on a web application by vision. This eliminates the need for hard coding with Accessibility IDs or other such locators. Furthermore, intelligent automation tools are now able to use OCR and other image recognition techniques to visually map the application and locate visual regressions, or verify elements.
- AI Analytics of Test Automation Data: Tests generate copious amounts of data which has to be combed through in order to derive meaning. The application of AI to this process greatly increases its efficiency. AI algorithms can be used to detect and categorize errors. More sophisticated applications of AI algorithms are also able to identify false negatives, and true positives in test cases. This can be very helpful and greatly reduce the workload of QAs.
A Case Study to Explore the Potential of AI: Spidering Web Applications with AI
The automation framework Selenium was originally designed to simply test web applications. However one of the more diverse uses of Selenium is web crawling, also known as spidering. While faster tools for spidering, such as the scrapy library in python are available, Selenium is best for the more complex applications.
Selenium can be used to spider an application and collect relevant data such as screenshots, and download the HTML of the application with beautifulsoup. Following this it can learn from the data collected how the web application should look and function. An unsupervised learning technique such as anomaly detection could be applied here to find anomalous elements or visual regressions. Supervised learning can be employed to do this as well; by providing screenshots and HTML data with labels to a classification algorithm.
Once the algorithm is able to successfully identify issues in a test run with the web application. It can be deployed on the same web application repeatedly to identify changes or irregularities, flagging them as possible bugs for further manual review.
The Future of AI
Artificial intelligence is a field of endless possibilities, and every year the use of AI algorithms to carry out intelligent test automation grows more sophisticated. Therefore, although a lot of the AI test automation tools are still in their infancy, it can clearly be seen that there is great potential for AI to revolutionize the future of software testing.
BrowserStack allows users to perform automation testing on 3000+ devices, browsers and operating systems. With Browserstack users can test AI programs like chatbots and perform automated tests using different languages and a variety of frameworks.