Most web sites will have forms, places were a user can add details in order to provoke an action from the web site. Stuff like signing up to a customer account or a checkout were you have to add your address and payment details. Most forms will have some sort of validation so that the data entered by the user is usable by the web site and also to help the user to avoid mistakes.
The eCommerce site that my company users has lots of different forms and i wanted to write some comprehensive automated regression tests to check that the validation was working after we did any changes to the site. I was specifically interested in testing the input combinations that should be allowed and ones that should provoke an error that is displayed to the user.
I was not looking at how the form should handle the incorrect format of an input e.g. wrong format of email address, but rather the combinations of good data that could be entered into the form.
For example we have on the site a contact us form, see screen shot below for the form fields:
There are a number of fields on this form that are compulsory and also there are different combinations of entries that are allowed and other ones that are not allowed.
The first thing i needed to do was to get all the possible combinations of inputs for this form. Not all of these will be valid but we can start to narrow down the test cases once we have created them all.
luckily there were a few tools available that will create a truth table of results when you give a number of different input fields. I used this one:
For the contact us form that has 9 input fields you just have to add nine fields into the truth table solver and hit solve. It will then spit out a matrix that should include every combination of inputs that are possible for the form. Next pop this into spreadsheet application, you should end up with something like this:
The ‘1’ in a cell indicates a valid input and the ‘0’ in the cell indicates no input.
You can see from the screen shot that the test results for these cells (This is just the first few rows in the sheet, there are 513 rows in the actual sheet!) are N/A that means that the combination of inputs for that row is not actually possible. You have to go thru your results and identify these cases along with the ones that will allow the form to be submitted and the ones that will provoke an error and shouldn’t allow the user to submit the form.
Now you will have a list of tests that will cover all the possible combinations of good data input, next thing is to create scripts that will test all your identifed tests that pass or fail.
Part 2 of this blog will focus on creating those automated scripts using the json format script that can be run using selenium builder!