I have a problem that is a bit more complicated than just transferring from uppercase to lowercase.
The automation begins with getting famous soccer player’s names from a excel workbook and then in a for each loop searches for each player on a web page, and then lastly click on the correct soccer player using a selector which is combined with row(1).ToString.
The problem that I encountered however is that the names in the list are not exactly structured properly. Some names are written like “Bernd LENO”, “Andrew Robertson” etc… Since “Bernd LENO” is written with his last name in all caps, the selector does not recognize that and can not click on the player’s hyperlink.
Is there any way to before clicking the name, make it so that “Bernd LENO” > “Bernd Leno”?
This occurs for a lot of players in the list, so it is not only a solution for one player but in general…
You can try this:
row(0).ToString.Trim.Tolower - make it lower case
row(0).ToString.Trim.ToUpper - make it upper case
You want like Bernd Leno?
Yeah exactly. And as you can see in the attached screenshot, there are names that are just their first name like “RODRIGO” that I would like to be converted into “Rodrigo”, with the capital “R”.
Try this,
Import namespace system.globalisation
Then
Convert all your input string to lower case and store into a variable
Assign lowerCaseVar = yourVariable.Tolower
system.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(lowerCaseVar)
Please mark as solution if this helped.
Thank you for helping me with this problem.
I have System.Globalization imported I think. It is in the imports tab at least.
I also added the assign activity, but I am not sure how to complete your last step?
What should I do with that “system.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(lowerCaseVar)”?
Edit:
For some more context my selector looks like this:
“<webctrl id=‘*’ tag=‘A’ aaname='”+row(1).ToString+“/>”
Assign this script to a new variable.
Assign ConvertedCase = system.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(lowerCaseVar)
Oh, ok!
And that newly created variable goes into the Selector instead of “Row(1).ToString”?
I will see if it works
Yeah exactly.
It does work with converting the text from “Bernd LENO” to “Bernd Leno” and same with “RODRIGO” to “Rodrigo” etc by checking it in a message box. However when I try to use the variable in a selector, it gives me an error of “The selector is not valid”. Which is odd because if I were to put the actual name in the selector (Bernd Leno for example) it works
Show me your selector with variable inside.
- Open the Expression Editor.
- Right Click on the attribuite you wanna change.
- Select choose variable to assign those variable in that location.
Since the location of the names changes, is that a viable option?
Either way, the problem was solved because I saw that I was missing a " ’ " sign after the convertedCase string… Small mistake but still caused an error
The name will be always under aaname i suppose. Hence there will be no issue. Otherwise you have to collect all possible outcomes and assign variables.
Yeah you can manually key in the variable within double quotes or you can just right click and select variable which will be error free as uipath does the syntax.
Please mark as solution if helped. thanks
Oh so you can assign that variable (convertedCase) in the actual selector by right clicking on what’s in the tag? I was reading a lot that you should NOT edit the selectors variables withing the Ui Explorer/Selector, but to do it only through the properties selector…
Either way, I learned a lot and you helped me out a ton. Thank you so much!
Even though the initial problem is solved, I figured I would ask a follow-up question here that appeared after trying this solution out.
There are sometimes names that have not so normal characters in them, such as “Sead KOLAŠINAC” for example. This throws an error because the names that appear are “Sead Kolasinac”, with a normal “S”. Is there any way to convert such characters or is that too much magic?
@Robert_Wennberg Try This:
System.Text.Encoding.UTF8.GetString(System.Text.Encoding.GetEncoding(“ISO-8859-8”).GetBytes(“Sead KOLAŠINAC”))
Thanks for the response!
How would I implement that into the selector that I am currently using though?
And also, there will be several cases with odd names such as “Piotr ZIELIŃSKI”, “Paco ALCÁCER” etc. Is there some universal way to make the names only into the standard alphabetic characters?