I’m working on a web automation project where I need to validate multiple input fields on a web form. Specifically, I want to:
1. Verify if each field is present on the page (e.g., First Name, Last Name, Gender, etc.).
2. Check whether each field is marked as required (either via an asterisk “*” next to the label or using attributes like required=“true” or aria-required=“true” in the HTML).
The form has various field types including:
• Text inputs (e.g., Name, Phone)
• Dropdowns (e.g., Department, Gender)
• Radio buttons (e.g., Surgery: Yes/No/Unknown)
• Date pickers (e.g., Date of Birth)
My goals:
• Log whether each field exists
• Log whether it’s marked required or optional
• Handle ~20 fields in a clean, maintainable way
⸻
Questions:
1. What’s the best approach to loop through and validate multiple fields efficiently?
2. Any best practices for handling radio buttons or dropdowns in this context?
You can store your fields which you need to check, store it in config file in row with comma or any separator,
You can get that from config file, which will be stored in string
Convert that string into list
Then use that list in for each and check each element avaialable or not in your application with check app state activity. To check whether it is mandatory or use get atrribute activity.
To identify the selector which you can match with input name and UI element name use UiExplorer, it will give best results.
Thanks! Just to clarify — my question is more general and applies to any screen with 20+ fields, where I need to check:
• If each field exists
• Whether it’s required or not
I’m looking for a clean and scalable way to validate all these fields — instead of writing 20+ separate checks manually.
When you work with any ui screen all screens might not be same or might not be coded in the same way
If you know the screens backend is same then we can make it similar and scalable
if the screens are different then its not possible that way
there are new ways coming in using agents like ui agent which is in preview which can work with different screens as well
to give an example
say firstname is a field that you want to check..in one of the site it would be under a div tag in another side it can be under an input tag and in another it can be under span tag..you cannot bring all 3 different firsts anmes from different types of screens and sites under one code that is quite out of scope as of now
but say if all the sits have first name with id as firstname and tag as div or anything which is similar then the approach of making it reusable across sites can be done
Just to clarify — my original question is specifically about a single screen (within one application)
so my goal is to build a clean and scalable way to:
• Check if each field exists
• Check if it’s marked as required (using either asterisk or HTML attributes)
just looking for best practices to avoid writing repetitive checks for 20+ fields on the same screen.
As you have already classified fields as text box dropdown etc that helps
Now you need to identify attributes which are similar and which attributes represent each field and use similar selector with variables
For example a textbox field can have similar attributes like tag and class and then name field will differ based on field add variable in that place to get all the text boxes