I need to validate, in a web page, after a submit an empty form - that 2 icons are appearing in the mandatory fields.
The icon is the same, and the difference in xpath between the 2 icons is only the position in webpage, a div number[].
Is not a stable solution, this number can be changed after a new version of the website is released and design is changed. Also image validation is not a good solution.
//*[@id="baseComponent"]/mat-sidenav-container/mat-sidenav-content/div/one-new-patient/div/one-patient-form/div/div/div[1]/div[2]/div/div[10]/mat-form-field/div/div[1]/div[2]/mat-icon
//*[@id="baseComponent"]/mat-sidenav-container/mat-sidenav-content/div/one-new-patient/div/one-patient-form/div/div/div[1]/div[2]/div/div[11]/mat-form-field/div/div[1]/div[2]/mat-icon
As you see the difference is only the div[10] , div [11]
So, the solution was to create a new xpath for both elements, a xpath which is founding 2 elements in tracking.
.//tag[#'baseComponent']//tag[@tagname='mat-icon' and @ng-reflect-svg-icon='icon_warning' and @svgicon='icon_warning'] this xpath is found 2 elements, the 2 icons.
I will need to create a user code and count the number of elements found. So test will pass if two elements for the same xpath are found.
Is this possible from the user code? Should I use Find method for the web? I am more a Java automated developer, so #C is not so friendly for me, at this time

Thanks