How to check fields present on screen or not

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

Please help

Hi @Akshaya89

You can use Element Exists or Find Element activity to check if each field is present on the page.

Happy Automation

@prashant1603765

I don’t want to use validation for each field.

Is there any way that I can validate all fields at once?

Hi @Akshaya89,

You will need to use selectors for those elements to find out whether they exists or not.

Various options as below:

  1. use element exists activity to check whether element exists or not.
  2. 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.

Hope this helps.

Regards
Sonali

Yes @Akshaya89

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.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.