How to ensure required fields cannot be left empty in Browser library

There are 6 forms. On each form, there are 6-7 required inputs(text, date,time, dropdown, radio). How do I test all of these?

1 idea is filling all input except for one and seeing whether it says input required or not when submitting it, and doing this one by one for each input in each form. But that sounds incredibly time consuming and exhausting.

Is there a better way to do this? I dont know if for loop works here either since there are so many different fields.

Hi Roshan,

The answer to this is going to vary depending on your application as every app will behave differently there will not be a single correct answer.

What you suggested is a valid approach, it’s also a useful way to check the form validation is working in your app.

Some nice applications have a asterisk (*) often in red next to the labels for the required fields, so you could use an xpath on this asterisk to find the require fields.

Some very nice apps will even remove the asterisk when the required field is filled, if you have one of these you can do a count of the asterisk’s and if zero submit the form and then validate you did not get a warning about required fields

hopefully this helps,