IF...Else Conditions based on web page data

Hi Community,
Question regarding how to use web page data in an If…else condition.

I enter data into a web page. When I press enter, it will either

  1. Say no records found
  2. Give me a list to search through and select one
  3. Take me to a data entry page where I can input data
    Depending on which of these results appears, I would like to continue along a UI Path.

I have used UI Explorer to get unique target selector details from each web page.
IF 1 - Message
webctrl aaname=‘No matching values were found.’ tag=‘SPAN’ class=‘PSSRCHINSTRUCTIONS’ parentclass=‘PSSRCHPAGE’
If 2 - List
webctrl aaname=‘Search Results’ tag=‘SPAN’ class=‘PSSRCHSUBTITLE’ parentclass=‘PSSRCHPAGE’

If 3 - Data Entry
webctrl aaname=‘Transcript Text’ tag=‘LABEL’ class=‘PAPAGETITLE’ parentclass=‘PSPAGECONTAINER’

I’m trying to create if statements to say
If 1
Do X
If 2
Do Y
If 3
Do Z
Error Message

The If statement in UI Path requires a VB Expression.
Am I able to say If aaname=“Search Results” somehow. I’m unsure of VB code so do not know where to start. What VB expression to use.

Thanks in advance,

*** Edited to enable webctrl details to appear.

Yes you can use Get Attribute activity to find value of aaname by passing the UIelement as input. But I would recommend Switch activity here instead. Have a variable set the value according to requirement like message, list or Data entry and have a switch

@pobox90210 The best way to use is Element Exists check. For every option you specified, check the element exists.

Hi all,
Thanks for the details. I’m almost there I think, however I receive a message “The UiElement is not initialized”.
The answer in the community for this doesn’t seem to help.

I have attached a screenshot of the area of the get attribute. Perhaps there is something obvious in my setup that I cannot see.


Get Attribute activity takes input as UiElement so you need to first give it a valid UiElement

Sorry, I don’t understand. I guess I’m trying to create this before I actually understand UIPath and it’s technical jargon.
When I hit the search button in the previous step (not in picture), output is one of the 3 “webctrl aaname=” above. I was hoping that switch would take the aaname and check which one it is and follow that path/process.

So for Input into get attribute aaname in the picture above I use aaname as input to load the value into aaname variable I created so switch can use this. Clearly this is not correct.

Are you saying that I should (using picture above, in Get attribute aaname box)

  1. Clear Input attribute of aaname
  2. Clear target selector of “”
  3. Enter Target Element with aaname.
    Only I’m not sure it likes a string which is what aaname is.