I have one requirement, in a website I need check all shown above fields from the above image are present or not. If any of those fields are missing I need to throw the exception for that field.
Can anyone suggest me how can I validate all fields at once? And I don’t want to use separate validation for each fields
You will need to use selectors for those elements to find out whether they exists or not.
Various options as below:
use element exists activity to check whether element exists or not.
Use CV element exists activity to check. For this you will use this screen as cv screen scope, then check each element by using element exists property.
Create a list of selectors:
fieldSelectors = New List(Of String) From {“selector1”, “selector2”, “selector3”}
Check if any field is missing using LINQ:
missingFields = fieldSelectors.Where(Function(selector) Not ElementExists(selector)).ToList()
Throw an exception if any fields are missing:
If missingFields.Any() Then Throw New Exception(“Missing fields: " & String.Join(”, ", missingFields))
This will check all fields in one go and throw an exception if any are missing.