Doing more with less: AI-Powered Test Automation

Doing more with less: AI-Powered Test Automation

 

AI-Powered Test Automation is a great way to help you do more with less. Murphy’s twelfth law states that whenever you set out to do something, something else must be done first. In Test Automation this inevitable forces you round the loop of writing test after test after test. Even when you know that this is something that should be done once and then reused over and over again.

To demonstrate how to do more with less code let’s look at the case of testing deposits using our digital bank. Deposits can be made into Savings or Checking accounts.  As we create more accounts, we have more to test. To find out how many accounts there are to make a deposit in, we look at the drop down menu. It will contain all of the accounts available and we need to make sure we don’t go beyond that list. This is where WebdriverIO can help us.

Next-gen browser and mobile automation test

The first snippet of WebdriverIO code needed, is to extract the total number of accounts from the drop down menu. We can achieve this by first finding the drop down menu elements using the css selector ‘#id’ on line 19. Then daisy chaining this to the findElements(‘css selector’, ‘option’) method in WebdriverIO on line 23. Once we return the JSON object we can get its length on line 24.

AI-Powered Test Automation

AI-Powered Test Automation variability

So now we know how many accounts are available to make deposits in, we need to test each account deposit in turn. This could be done by counting from zero to the total number of accounts available and making a deposit in each account. But is this a realistic user behaviour? It would be better to use the power of variability to select one of the accounts in the drop down. A different account is chosen, each time we come to make a deposit.

We need to make sure we do not try to make a deposit into an account than does not exist. (i.e. more than is in the drop down menu). Using the auto-generation of test data in Vitaq AI with the ‘requestData’ method we can auto-generate a selection for one of the available accounts. The Vitaq AI Test Activity variable ‘accountNumbers’ is defined as any integer number between 1 and 20. Each time we request it, it will ‘vary’. By using AI-powered test Automation, we can set coverage targets to ensure we get to deposit in every account at least once.  

AI-Powered Automation

AI-Powered Test Automation

Constraint-driven generation

To ensure that we always get an account that is less than total number of accounts available. We have implemented a while loop in the code below. It tests that the Vitaq activity variable auto-generated is less than total in the drop-down list. If now, it will generate it again until it is acceptable.

AI-Powered test Automation

Now we’ve got everything we need in the code snippet. Each time Vitaq AI selects the Deposit ‘Action‘ in the activity map. It will select a different account to make a deposit into. Behaving just like a real user. Using Vitaq’s #reinforcementlearning algorithms, your Test Automation will auto-generate deposits into each account in the digital bank. It will also deposit a different amount each time, always pushing the edge-cases.

AI-Powered Test Automation

The complete Test Action script for testing a ‘deposit’ into every account in the digital bank app is shown above. So as you can see we are doing more with less, all driven by AI-powered test Automation. Vitaq AI’s activity map will navigate realistic user-journeys depositing different amounts into different Savings and Checking Accounts each time it runs.

Leave a Reply