Selector error- Get text

Hi all, please help on a better option or how to stabilize the selector here, it keeps on changing and I have used the wild cards but still unstable:

I am trying to get the value in Red but it changes and gives me the value in green



Any suggestions to help please

Hi @Anelisa_Bolosha1,

I guess you were trying to get the value from red but it’s giving you the green value. I would recommend provide a proper Anchor for the value you would like to extract, follow the below steps using Modern UiPath Activities:

  1. Anchor selector → target the “Contract Premium” label cell by text, not row
    For example, the selector should look something similar to this:
    <webctrl parentid='CntContentsDiv*' tag='TD' innertext='Contract Premium' />

  2. Target → indicate the value cell next to it.
    For example, the selector should look something similar to this:
    <webctrl parentid='CntContentsDiv*' tableCol='2' tag='TD' />

This way, wherever “Contract Premium” sits in the table, Anchor always grabs the adjacent value, it stops caring about tableRow entirely, so it won’t drift to “Lapsed” or any other row again.

Also add the safety parse check so if it ever does grab the wrong cell, it fails safely instead of crashing:
If Double.TryParse(extractedText.Replace("R","").Trim(), premiumValue) Then proceed, Else log and skip/retry

I hope this helps.

Cheers!

Hey @Anelisa_Bolosha1 ,

Your tableRow='*' is the culprit — it grabs whatever TD comes first, so sometimes you get Contract Status instead of Premium. And CntContentsDiv10 will break too, that number shifts.

Drop the row/col indexes and anchor off the label instead.

Find Element:

<html app='msedge.exe' title='HOLLARDPFS*' />
<webctrl innertext='Contract Premium*' tag='TD' />

Get Text (inside the anchor):

<webctrl tag='TD' />

Rows can move all they want now.

Second thing — your Assign will still blow up even with the right cell, because of the “R” and the comma. Clean it first:

strClean = System.Text.RegularExpressions.Regex.Replace(strPremium, "[^\d\.\-]", "")
dblPremium = Double.Parse(strClean, System.Globalization.CultureInfo.InvariantCulture)

Works for R 259.36 and R -3,050.00 both.

Also wildcard the title, and run Validate on 3-4 different contracts before trusting it.


Source: LLM-assisted, verified against UiPath documentation.

Hi @Anelisa_Bolosha1

anchoring on the label is the right call, just one thing worth checking when you test it. In tables like this the label and the value are usually sibling TDs, so a plain <webctrl tag='TD' /> as target can end up matching the label cell itself instead of the one next to it

if that happens, the easiest fix is telling the anchor wich direction to look, the Anchor Base has a position property for that, or in the modern activities theres an anchor direction on the target. Setting it to the right side usually solves it in one click

and if the value cell has any attribute of its own, like an id or a class, adding that to the target selector makes it unambiguous without relying on position at all. Worth opening UI Explorer on that cell just to see what it has

hope this helps you as well !!

@Anelisa_Bolosha1

As per error its clear that the selector used is not unique..

So first show the ui explorer screen by indicating what you need or select which are unique..may be table id or name..or a reliable td and then nav up and the get the required td

Cheers