Tips & Tricks – Automated Form Testing
Forms are everywhere in software and online experiences. They let users register, log in, provide feedback, make payments, and more. Because forms are such a critical part of interacting with an app or website, they need to work perfectly.
If you’re looking to automate testing, then you will encounter forms.
But how well do you know forms?
Read on to get an in-depth understanding of form testing and how to automate it.
Why Automated Form Testing?
Here’s why automating form testing is crucial:
Central to User Experience
Imagine a user trying to sign up for a service, but the form keeps showing an error for no reason, or the “Submit” button doesn’t work. These problems frustrate users and can lead them to abandon the process. Automated testing helps catch and fix these issues early and ensures smooth and hassle-free user interactions.
Forms are Complex
Modern forms are not just simple text boxes. They often include:
- Drop-down menus
- Radio buttons
- Dynamic fields that change based on what the user selects
- Real-time validation (like checking if an email is valid as you type)
Testing all these combinations manually is tedious and prone to mistakes. Automated testing can handle these complexities quickly and accurately.
Manual Testing is Time-Consuming
Think about all the different things you need to check in a form:
- Is every field working as expected?
- Are error messages shown for invalid inputs?
- Is the form working on different browsers, devices, and screen sizes?
Manually testing all these scenarios is slow and repetitive. Automated testing speeds this up and allows testers to focus on more strategic tasks.
Forms Need to Be Secure
Forms are a common entry point for hackers. If a form isn’t tested properly, it can lead to:
- SQL injection attacks: Hackers trick the system into revealing sensitive information.
- Cross-site scripting (XSS): Attackers can inject malicious code into the form.
Automated tests can simulate these attacks and ensure the form is secure.
Drive Business Outcomes
For many businesses, forms are directly tied to revenue. Think of an online store’s checkout form. If it breaks, customers can’t make purchases, and the business loses money. Automated testing ensures that these revenue-critical forms always work as expected. Read: Software Testing for All Industries.
Forms Must Work Everywhere
People access forms from all kinds of devices and browsers. A form might work fine on Chrome but fail on Safari or look great on a desktop but break on a mobile screen. Automated testing tools can quickly check forms across different browsers, devices, and screen sizes to ensure they’re universally accessible.
Fast Feedback for Developers
When developers make changes to a form, automated tests can instantly check if something broke. This quick feedback helps developers fix problems faster and keeps the development process moving smoothly.
Reduces Human Error
Manual testing relies on humans, and humans can miss things. For example, a tester might forget to check an edge case, such as when entering special characters into a field. Automation testing ensures that every scenario is tested consistently and nothing is overlooked.
Objectives of Form Testing
Form testing is all about making sure forms in web or mobile apps work exactly as they should. Forms are a direct way for users to interact with your application, so testing them thoroughly ensures they function smoothly and provide a great user experience.
Validation Checks
When users fill out a form, you want to ensure they provide the right kind of information. This involves:
- Required Fields: Checking that users cannot leave important fields blank. For example, if an email is required, the form should display an error message if it’s missing.
- Field Formats: Ensuring data like emails, phone numbers, or dates follow the correct format (e.g., “[email protected]” for emails).
- Limits: Testing the maximum and minimum lengths for fields like passwords or text boxes to prevent errors or misuse.
Functionality Testing
The buttons and actions on a form need to behave as expected. This includes:
- Submit Button: This ensures that the form data is correctly sent to the server when the user clicks “Submit.”
- Reset Button: Verifying that all fields are cleared when users click “Reset.”
- Navigation: Check that the form redirects users to the right page after submission, such as a confirmation page or thank-you message.
Usability Testing
Forms need to be user-friendly and intuitive. This involves:
- Ease of Use: Labels, placeholders, and instructions are clear so users know what to do.
- Error Messages: Test whether helpful error messages appear when users make mistakes, like “Invalid email address” or “This field is required.”
- Field Alignment: Make sure fields and buttons are aligned correctly and look good on all screen sizes.
Security Testing
Forms are often targets for hackers, so they must be secure. Security testing ensures:
- Preventing SQL Injection: Hackers can try to input malicious code into text fields to manipulate your database. Testing ensures this doesn’t happen.
- Avoiding Cross-Site Scripting (XSS): Ensure attackers can’t inject harmful scripts into forms that can affect other users.
- Data Protection: Verify that sensitive information (like passwords or credit card details) is encrypted and securely handled.
Cross-Browser and Cross-Device Compatibility
Users access forms on different browsers (Chrome, Safari, Firefox) and devices (desktops, smartphones, tablets). Automation tools can test:
- Different Browsers: Chrome, Firefox, Safari, Edge, etc.
- Different Devices: Desktop, mobile, and tablets.
- Responsive Design: Ensure fields, buttons, and error messages look and function properly on different screen sizes.
Dynamic Behavior Testing
Modern forms often change based on user input, and testing ensures this works correctly. For example: If selecting “Yes” in a dropdown reveals more questions, these fields should appear at the right time and function properly. Testing conditional logic ensures fields hide or show based on the choices users make.
Read: Comparing Testing Methods for Static vs. Dynamic Web Applications.
Performance Testing
Forms should handle different scenarios efficiently, such as:
- Multiple Submissions: Test how the form behaves when submitted multiple times in quick succession.
- Large Data Inputs: Ensure the form can handle long text entries or large file uploads without crashing.
- High Traffic: Make sure the form works smoothly when many users access it simultaneously.
- Submission Speed: Verify that the form is submitted quickly without delays.
- Error Handling Under Stress: Check if the form handles server issues gracefully, like showing a clear message when the server is down.
Integration with Backend Systems
Forms often send data to servers, APIs, or third-party services (e.g., payment gateways). Testing ensures:
- Data is transmitted correctly and reaches the backend system.
- The system processes the data properly such as creating a new user or saving feedback.
- Any error messages from the server are clear and shown to the user.
Data-Driven Testing
Automated testing tools can use large sets of test data to check different scenarios:
- Valid and invalid inputs for all fields.
- Edge cases, like maximum and minimum values.
- Combinations of inputs across different fields.
This ensures the form behaves correctly for all possible inputs without needing to test every case manually. Read more about Data-Driven Testing.
What to Test in Form Testing?
Forms comprise different elements that need to be tested:
-
Form Fields: Forms usually contain different types of fields, and each one needs to be tested.
- Text Fields: Check if users can input data and if validations like “only letters” or “maximum characters” work correctly.
- Dropdowns: Ensure the list of options is correct and that users can select the right one.
- Radio Buttons and Checkboxes: Test if selecting and deselecting these options behaves properly.
- Date Pickers: Validate that users can select valid dates and that invalid dates are blocked.
Automated scripts can test all these fields quickly by simulating user input. -
Error Handling: Forms need to give helpful feedback when users make mistakes. Automation should verify that:
- Error Messages Appear: When required fields are left blank or invalid inputs are entered (e.g., typing letters in a phone number field).
- Clear Instructions: Users see messages like “Please enter a valid email address” instead of vague or confusing errors.
- Highlighting Issues: The problematic field is highlighted so users know where the error is.
-
Dynamic Elements: Some forms change based on what the user selects or inputs. For example:
- If a user selects “Yes” for a question, more fields might appear for additional details.
- If a user picks a specific country, the “State” dropdown might change accordingly.
Automation ensures these dynamic changes happen correctly and consistently. -
Validation Logic: Validation ensures the data users enter follows the rules. Automation should check:
- Field-Specific Rules: For example, email fields should only accept valid email formats, and phone number fields should only accept numbers.
- Required Fields: Ensure the form cannot be submitted unless mandatory fields are filled.
- Boundary Values: Test the upper and lower limits for fields like maximum password length or minimum age.
- Cross-Field Validation: Some forms compare fields, like confirming if “Password” and “Confirm Password” match.
-
Button Functionality: Forms often have multiple buttons, and their behavior needs to be tested:
- Submit Button: Test whether the form data is sent correctly and if users are redirected to the right page.
- Reset Button: Ensure all fields are cleared when the reset button is clicked.
- Dynamic Buttons: If buttons appear or change state (e.g., from “Submit” to “Processing”), automation can check this transition.
-
File Uploads and Attachments: If a form allows users to upload files, automated tests should validate:
- File Types: Only allowed formats (e.g., .jpg, .pdf) are accepted.
- File Size: Large files are rejected if they exceed the limit.
- Successful Upload: Uploaded files are processed and saved correctly.
8 Best Practices for Automated Form Testing
Here are some best practices to help you automate form testing easily:
-
Have a Clear Plan
- Understand the Form: Before you start automating, know what the form is supposed to do. Identify its fields, buttons, validations, and dynamic elements.
- List Test Scenarios: Write down all the cases you want to test. Include:
- Valid inputs
- Invalid inputs
- Missing data in required fields
- The behavior of buttons like “Submit” and “Reset”
- Prioritize Critical Tests: Focus first on the most important parts, like required fields or business-critical features (e.g., payment forms).
-
Write Modular and Reusable Scripts
- Modular Tests: Break your automation scripts into smaller, reusable parts. For example, create separate functions for:
- Filling out fields
- Clicking buttons
- Checking error messages
- Why This Matters: If something changes in the form like a new field is added, you only need to update one part of your code.
- Modular Tests: Break your automation scripts into smaller, reusable parts. For example, create separate functions for:
-
Test Across Browsers and Devices
Users access your forms on various devices (phones, tablets, desktops) and browsers (Chrome, Safari, Firefox, Edge). Use automation tools to run tests on multiple browsers and screen sizes to ensure everything works everywhere. You can make use of tools that offer such an array of devices. -
Validate Both Frontend and Backend
- Frontend Testing: Check what the user sees. Are the fields behaving correctly? Are the error messages clear?
- Backend Testing: Ensure the data entered in the form is sent correctly to the server and that the server handles it properly. For example:
- Verify the data is stored in the database.
- Test the server’s response to invalid or malicious inputs.
-
Use Continuous Testing
Forms change over time as developers update them or add new features. Use tools that integrate with CI/CD pipelines to run automated tests whenever changes are made. This catches issues early. Read in detail about What is Continuous Testing? -
Use Robust Locators
- What Are Locators? These are how automation scripts find elements on the page (like fields or buttons). Use locators that are less likely to change, such as:
- Unique IDs or names
- Stable XPath or CSS selectors
- Avoid using vague or temporary attributes like text labels, as these may change during development.
- These days you get generative AI-powered tools like testRigor that eliminate the hassle of working with such locator-related details. This makes automated software testing easy for everyone.
- What Are Locators? These are how automation scripts find elements on the page (like fields or buttons). Use locators that are less likely to change, such as:
-
Handle CAPTCHA and 2FA
CAPTCHA and two-factor authentication (2FA) are designed to stop bots, so they can make automated testing tricky. Use test environments where CAPTCHA or 2FA are disabled for testing purposes. Or else, you can use tools that can solve CAPTCHAs and 2FA. Read: How to do Captcha resolution using testRigor? -
Don’t Automate Everything
Some tests are better done manually, like checking for visual design issues or testing rare, complex scenarios. Focus automation on repetitive tasks and functional validations to save time.
testRigor for Form Testing Automation
login click on "New User" enter stored value "name" into "Full Name" enter stored value "phoneNumber" into "Phone" enter stored value "email" into "Email" click on "Submit" check that page contains "New User Created Successfully!"
You can do data-driven testing, end-to-end testing, regression testing, UI testing, API testing, and cross-platform testing too. testRigor offers powerful tools that let you automate 2FA, email testing, SMS and phone call testing, working with tables, and much more.
Here’s a video that demonstrates how to test different types of forms using testRigor. There is no reliance on implementation, so you can use testRigor to test any type of form. testRigor’s approach is the same as a human would view the form and execute actions.
Tips & Tricks Video
In this video, you’ll see how to test all types of forms effectively. There is no reliance on implementation so you can use testRigor to test any type of form. Our approach is the same as a human would view them. We will show examples of seamless testing of custom drop-downs, custom checkboxes and radio buttons.
Video Transcript
Artem Golubev: Hello everyone. Today we will be talking about automating testing of the forms; there are several challenges with automating testing forms which you would usually encounter. So, first of all, let me walk you through the specific features that testRigor has to simplify and what kind of challenges our customers usually run into before using testRigor. So this is an example on Safeway.com. So basically, some forms are elementary, for example, searching for products from a user’s perspective. However, if you try to rely on the idea, that might change.
TestRigor allows you to enter the data stably, depending on how it looks from the end-users perspective. In this case, we can say things like entering product to search products. Moreover, testRigor can also automatically associate whatever looks like the label from a user’s perspective. This is the input such that you can say things like enter test into first name and based on how it looks from a user’s perspective. Here is where it might be no technical association between first name tags and this input below. However, if you see an instruction “enter test” in the first name, you, as a human, intuitively understand that we were talking about this input below or rather than trying to figure out what to do with this text, but you associate this with test automatically, and this is what testRigor allows you to do easily. So you can do things like enter test in the first name and the last name. Finally, the next thing that testRigor can do for you is simplify working with their dropdowns, and another challenge working with dropdowns sometimes is that it is not always dropdown as instructed by HTML. In HTML the dropdowns are usually select tags option tags. However, in the modern application, frequently, there is just something that looks like a dropdown from a user’s perspective. However, it is not a dropdown. In this case, it’s straightforward to deal with on TestRigor. In the majority of the cases, you will be able to say things like enter April into a month or something like that in a birthday section, or our AI wouldn’t be able to detect that this is a dropdown when you can click on a month and click on an April. So we are making it very easy. So let’s practice this with the Safeway.com application. TestRigor also has a way to help you to express the steps in English that are not perfect, of course. But it will help you to speed up you are creating your first test app; after that, it will be faster to use the rules themselves instead of using this recording. Okay, so let’s sign up.
Connie Lund: Can you share your screen?
Artem Golubev: All right, let’s start again. I apologize that I wasn’t sharing the screen. Let’s start the application and start a new recording. So with this, testRigor will be able to help you to formulate the steps. Then let’s click on sign up and sign in. I want to use something we could use for testing here, and let’s sign in. Let’s close this and click on Account, and I want to go to Account settings; as you can see, now it looks different. Let’s click add for the birthday, and select on this particular case it will be [unintelligible]. Let’s select June as the month. I’ve left eight as the day, and let’s click save, and then we want to validate it is a fixed date.
Are they present on the field? Let’s stop the recording. As you can see here, it recorded the steps here for us. So this is what I was talking about; you can select June from the months and eight from day, click save, and then we can do the validation. And we pick it off. So once again, often, the challenge, as I was mentioning, is, in fact, that, like you should be able to deal with his custom dropdowns, custom checkboxes, nos kind of stuff, which testRigor helps you to automatically identify and use the same language you want to use in dropdowns. Moreover, testRigor uses AI and machine learning to detect various classifiers of dropdowns. It is easy to express everything purely from an end user’s perspective.
Let’s get into our project and see how our test is executing. This is our test, and here is an example we are going through. Let’s click on sign up and sign in. But in this case, the test will fail because there is no more info on the birthday. But hopefully, it illustrates the point. So let me select another example here. This is the test page, and that’s an interesting example here. Can we isolate selecting those checkboxes? So the thing is that you might have checkboxes, like in many places on the screen. Often, you need to select the ones related to, let’s say, gender and are in certain sections. So let’s imagine where multiple sections and multiple options are. Where we can select males and females.
In testRigor, you can specify exactly what you want to do here. Let’s create a new test suit for this application and select a female for this gender in this section. Create this and make it a Web Test. And the way you would do it is you can express it in the way you would say in English, and you would be able to say click on female or the right of gender or click on female below automation practice and on the right of gender. Let’s do exactly that. This indicator has a section on the nature of flow because it’s below on the right.
Let’s kick it off. So basically, as you remember, the way that testRigor works is it starts a web application. Like if you select some things to test on this case, Ubuntu or Chrome. Starts Ubuntu machine open chrome browser and loads the URL you specified when you created the test suits. And wait until the page loads and when it starts to execute, steps simulating how a human will run those steps. So as you can see here, it highlighted females because we were able to detect the section.
So we’ve got a section, and it got more specific things like gender and found a female on the right of gender. So we were able to click that. All right. And obviously they have a bug in here, because it doesn’t execute. In this particular case, there is an issue that this female is not associated with the radio button. So we would need to specifically fix that and instead of clicking on female, which doesn’t do anything. We’ll have to click on female, and then you still specify where this female is. You can check that; it will be associated automatically; you don’t need to do anything. So you always keep expressing everything purely from the end user’s perspective. Okay, so I guess this is it for a simple form. Working with forms examples. So as I mentioned, as soon as you can express something in English from an end user’s perspective, testRigor will be able to execute it for you. And let’s open up for questions.
Connie Lund: So one question is, can I fill in a form, submit it, and verify that the email was sent in one test?
Artem Golubev: Yes, you can. We have an example. Give me a second I’ll pull it up. So testRigor supports an actual test to be able to sign up for customers, and we have some examples. Sorry, and the part of the signup process frequently is that you need to verify the email and get data from the email because the email will contain some link or registration code you will need to use. Give me one second. Let me share my screen again.
This is an example of Twitter sign-ups where you go through the registration flow you enter many data into forms, as you can see here, and then basically, the last steps are when you sign up. It will send you an email, and we expect a verification code from your email. So with testRigor, if you generate a unique email using testRigors’ command when and save it, let’s say a new email, and you will be able to say hey, check that email and we will render it for you like a page. And you’ll be able to use the same commands you would usually use with testRigor to work with the carrier.
You can do validations, or in this particular example, we’ll grab a text below the verification code. Save it as a code and switches back, and we entered our Stored Value code into the verification code and clicked Next. So obviously…Like you can also continue if you don’t want to continue. Obviously, through registration button, but you can continue as you can imagine and finish the registration flow in this case for Twitter. And the point being is that you should be able to use it via emails and sometimes text messages to complete your signup flow. And testRigor supports various use cases out of the box. TestRigor runs its own testing email server so that you can send and receive emails if you use a particular domain. It’s all in the documentation. And you will be able to render those emails. The end user would order to extract the data and sounds forth to complete the four periods, let’s say email or text message.
Connie Lund: The last question is whether many automation tools struggle with dynamically created forms. For example, is this the same for testRigor?
Artem Golubev: No, it is not. There are two things that I think could go wrong here specifically. One is the fact that there are no unique stable identifiers for the inputs here, and that, as we discussed, is addressed by the fact that testRigor does not rely on details of implementation or how those inputs are implemented and outlined. And how it depends on how it looks from the end-user. You can use whatever looks like labels or placeholders or anything else. Somehow, if you have a way of expressing yourself in English. You may have to find elements on the screen. You will be able to do that with testRigor, and this is how to execute it and find it for you and be able to work. This is one. And as an example, I think what the question means here is the form is chain being changed dynamically as we go. And a typical example of that is in this example, if you select a month here, and you’ll be able to choose a day because other months contain a different number of days.
Another prevalent example is after you select the country, and if the country is the United States, you will be able to see another dropdown, which is a straight dropdown that is otherwise not visible. Again, testRigor will be able to process efficiently, so express the same be the select United States from the country and then select California from the state, and it will just work as you would expect because yet again, in testRigor, you were just writing what needs to be done for end-users the same way you would be writing a test case for a manual tester. So testRigor will emulate how the manual tester has worked, and as soon as you have selected the United States as a country in a dropdown, then the state dropdown will appear, and therefore, testRigor will be able to proceed. And, of course, it will automatically wait until his standard is done and appear as soon as it seems, it will continue.
Connie Lund: Right, excellent. So that’s the end of this session for today. Next Wednesday will be testing drag and drop functionality. So we hope you’ll join us then. Thank you.
Artem Golubev: Thank you.