How to write a custom code in UiPath and ask the bot to refer to it?

Dear @ClaytonM
I’m trying to automate the same process which I did for HSBC for Hang Seng Bank now. But the problem is again with the field selection on the website. Here the entries are in uppercase and I have made changes to my string accordingly. But the robot is still not able to identify which items to select from the drop down list.

Here is the error that I am receiving:

I have attached the workflow and sample excel hereMain (23).xaml (50.9 KB)

Book2.xlsx (8.7 KB)

Please also refer to my previous case here:

@badita @neonova @KarthikByggari @palindrome @kirti.iyer @PrankurJoshi @ovi @Stelian_Mustea @Divyashreem


Please try this selector

<html app='chrome.exe' htmlwindowname='_15441686146370.b0b3f919a778422aed784292161c7884_' title='Hang Seng e-Valuation' />
<webctrl id='select2-areaValue-result-*' tag='LI' aaname='KOWLOON' />

Change the first line as per your browser if required and in AAname field supply your appropriate temp variable

working for me

Note this works for one session, if the page is reloaded it doesn’t seem to be working (some sort of invisble selector is being changed in each page load)

1 Like

@neonova @loginerror @nadim.warsi @Alex_Cross @Manjuts90 @Rishi1

Dear All, I am trying to match the items in the block field against the excel entries under block.

As shown in the excel, Block name on the Hang Seng Bank website is “Beverly Villas Block 1”

on HSBC it’s just “Block/ Tower 1”

while on BOC it is simply a number ‘1’

Now if you look at the excel sheet: my entry is similar to that of HSBC but without creating another excel sheet for every bank how can I select correct block on every bank.

How can I modify my selector to suit it for every website and how can I make similar changes for every field to map it against excel entry for different websites.
Please advise with an example.

You may able to achieve a dynamic selector for a few websites but to make a generic selector, I dont think that would be possible as each website has its on UI elements arranged in their unique way

You can look into Regex to extract numerical/char values from a base excel and for each website if you know whether it needs a numeric entry (like in this case) or a char entry you can use a switch activity to choose an approriate case

Hi @neonova,

Requoting - “You can look into Regex to extract numerical/char values from a base excel and for each website if you know whether it needs a numeric entry (like in this case) or a char entry you can use a switch activity to choose an approriate case”

Please, can you demonstrate it to me with an example:

@loginerror @nadim.warsi @Alex_Cross @Manjuts90 @Rishi1

Please refer this. im sure some searches around the forum would help you understand Regex

else refer this

@nenova @loginerror @nadim.warsi @Alex_Cross @Manjuts90 @Rishi1 @Gabriel_Tatu @claytonM
Please, can you demonstrate to me how can I implement it in the above scenario. I am unable to connect the dots.

Hi @Tom1989

I know you have been asking similar things in a private mail as well, but I’m briefly looking over this as well, and from my understanding…
You have an Excel value which could be “Block/Tower 1” and the dropdown will have any text followed by “1”

(ie “BEVERLY VILLAS BLOCK 1” or “1” or “Block/Tower 1”)

So essentially, you would just want that number on the end. There are many approaches, but you could just wildcard everything before the last word (ie “1”)

blockValue.Split(" "c).Last
So, you can do that in your assign like this:
temp3 = row("Block").ToString.Split(" "c).Last
with your selector being with wildcards around it like this: aaname='*"+temp3+"*' />
or do the manipulation in your selector like aaname='*"+temp3.Split(" "c).Last+"*' />"
—EDIT: also keep in mind that splitting by the space requires a space is there, so you need extra robustness to avoid future issues. You can add inline If statement to check if it contains a space like this: If(row("Block").ToString.Contains(" "), row("Block").ToString.Split(" "c).Last, row("Block").ToString)

So by taking the last word, the aaname will become like "*1", and will look for any aaname where it ends with a 1 or whatever number is there.

Since you are using different websites, make sure you can use the Select Item activity first rather than the Click followed by another Click using the aaname. If you can use Select Item, it makes choosing the item a little easier and more dynamic, but also will slightly change how you approach selecting it, because you wouldn’t want a wildcard in that case.

My next tip would be is that one site has all the values in Upper Case. For that site, make sure you are using .ToUpper to the values when selecting them.



Hi @ClaytonM,

I am working on a project where I have to capture different residential addresses (not really in a standard format - because the format could be in the following 2 formats:

Format 1:

Flat - Takes just one line
Floor - Takes just one line
Estate Name (or it could be ‘Building Name’) - In one or two lines one below other, for example: “Wah Yeun
Street Name - Could Take one or Two Line
District - In one line
Zone - In One Line

Format 2:
Flat, Floor, Estate Name - All three fields are present in one line separated by commas.

Street Name - May or May not be in the same line as Flat, Floor, Estate Name

District - Separate Line

Zone - New Line

Above are the two formats in which the residential addresses might exist on the PDF document.

I have to do the following:

  1. Capture the residential address

  2. Split various fields (Flat, Floor, Street Name, Estate Name (or Building Name), District & Zone)

  3. Select these different fields on different property valuation websites (HSBC, Hang Seng and BOC)

(Note: To perform valuation on BOC, one activity involves entering Captcha)

And Copy the result as PDF and save it on the client’s online application.

Now, the differet websites have different field names and I don’t know how to split the residential address to map it against the correct field on different websites.

Another challenge I am facing is sometimes, the field names are stated as abbreviation in the residential address for example, instead of ‘Alexander Street, Wong Tai Sin’, it could be -

‘Alexander- Street, WongTaiSin’ (Note: Wong Tai Sin district is written as one word without space)


‘Alexander Street, WTS’ (Note: Wong Tai Sin District is abbreviated)

I have prepared an excel sheet by referring to different fields on HSBC, Hang Seng and BOC and have assigned mnemonics to a few fields as attached here: Mnemonic - Property Valuation Project.xlsx (29.2 KB)

I haven’t done the mnemonic creation for other fields such as Building Name (Estate Name), Street Name, Floor, Flat.

Because, the data is humongous and I can only assign mnemonic to fields that I am sure about (Zone and District)

How to automate this process?

Can you advice me on this?

@TejusVenkatesh @neonova @nadim.warsi @loginerror @Madhavi @KarthikByggari @badita @Alex_Cross @RishiVC1

Tom one of the best way to do this and remove selector dependency would be to use find children activity in combination with Select Item Activity.

Part 1 of the Problem

Using Find Children you can get the details of all the values available inside a particular drop down, okay how you will you do that? Follow the below link.

How to get names of the filed from the Find Children activity

Okay, so far so good. We have devised a way to get the list of the fields that we are supposed to select from the drop-down.

Part 2 of the Problem
The Challenge in selecting the right item from the drop-down, we will be using the string manipulation along with for each.

  1. once you get all the children and their name (as visible, aaname), start matching them with value as read from excel.

For example: If the list of all names from the Dropdown Flat is stored inside variable named varUI_ChildDetail, and the flat value as read from excel sheet is A1, then you will loop through all the elements of the varUI_ChildDetail and will break out of the loop if the child aaname.equals(A1).

  1. If the value is matched, then pass the matched Aaname value to select item activity.

But where is string manipulation?

Part 3 of the Problem
Before we compare the values with aaname of the children, er need to clean the data as read from the excel and get it in the required format ( the way it displayed in under the drop-down)

  1. Block: Manipulate the column value to extract only digits. | Regex to get NUMBER only from String

  2. Estate Name: Replace new lines with space or null (whichever is applicable in this case)

Similarly, try to do the manipulation for other vales.


if you are able to extract the names/values and the only problem is comparing them, then remove all the special character form the obtained string convert to lower and then compare them. The result will look like this. ( You can do the same for Aanaes while comparing them )

Alexander Street, Wong Tai Sin’ = alexanderstreetwongtaisin
Alexander- Street, WongTaiSin = alexanderstreetwongtaisin

Regex to remove all special characters from string?

I hope this was helpful. Cheers. :metal:

1 Like

Hello @Tom1989 dare I ask are you still looking for some advice? :smile:

Due to the complexity, I don’t know how much help I can provide, but I’ll give some tips.

First, you need to extract the fields from the PDF. This might be the most challenging. To be honest, I can’t help identify the best approach to this, because it depends on the structure of the PDF file. But if we assume you need to use the Read PDF to extract all the text from the file, then I can help you with Regex or String manipulation to pull in the various fields that you need, which in that case I would need to see the RAW text data that you extracted from the Read PDF.

So, that’s the challenge is extracting the fields from the PDF text.

You say they are in 2 formats, well you can identify which format by using a Regex pattern, then proceed to extracting the fields on the format that was identified. But like I said, we need to see the RAW text from the PDF file or an example of it anyway. Alternatively, if the PDF is structured a certain way, you might not need to do any of this, if Data Scraping works; it depends on the PDF file though.

So, by using a Regex pattern, you can determine which format it is under, then have 2 other Regex patterns to extract the text for each format or you can also use the .Split method instead of Regex.

After you have all the fields correctly stored in variables, then comes (what should be) the easy part. You can simply replace all spaces and specials with a wildcard for use in the selector. See @RishiVC1’s link to doing this.

From my understanding, this pseudocode might look like this:

Read PDF file
Identify which Format // If Regex.Match(text, format1Pattern).Success, If Regex.Match(text, format2Pattern).Success
    Assign each field based on the format

Navigate website and input fields while replacing spaces and specials only for the sites that require the item in the selector

Lastly, make sure you are trying the Select Item activity rather than the Click + Click selector method, because the Select Item will change how you input the field dynamically so depends on the website.

Hope that helps in some way.


1 Like

Thanks @ClaytonM, I have already begun working on the project. May I text you on the forum or send you an email if I get stuck?