Make a selector language invariant

Can someone tell if it is possible to make a selector language invariant?

I know the selector can vary between english and portuguese. For example: title=‘Sign in your account’ or title=‘Iniciar sessão na sua conta’

Is it possible to do add an OR operator or do you have other suggestions?

hi @Fer

i think is possible, with “parallel” activity, just compare the two selector. Hope it helps

Regards

Hi @Fer,
There is one way to achieve this.
lets assume you have to perform click activity using any one of above selectors.

Use Try catch and place click activity inside catch with title=‘Sign in your account’
and in exception block place the same click activity but with title=‘Iniciar sessão na sua conta’

probably there would be another ways as well but, you can consider this as well.

Hope this will work for you.
Thanks!

@fernando_zuluaga, I am not sure if the parallel activity is the best solution since it increases the automation time a little bit.

@Deepak94, I think your solution has the same issue than the fernando_zuluaga solution presented. The main goal is just to make the selector as culture invariant as you can do with time and dates. Something like System.Globalisation.CultureInfo.InvariantCulture

Indeed, I really appreciate your help :slight_smile:

I have tried something like this before and it doesn’t work, the activities cannot search for things in parallel and will only do the left-most one from what I’ve seen.

Instead, I would suggest ensuring that it’s one language or another if possible, having an abstracted workflow what you can switch the language on, or using a for-loop.

@dmccammond, I had used the parallel activity for another example and it works fine. Take note that if the Condition property is set to True it will wait until one of the activities in Parallel is found. Otherwise, if it is set to False, it will wait until all the activities in Parallel are found.

I do believe that have it in just one language is the best approach when automating. However, since I developed the automation one day in portuguese and today when I runned it, the selector was not found due the change in the language, I would like to do something a culture invariant language.

so, i don’t know what to do in this case, i think you can’t change the language of selectors, maybe one solution is to recognize before any automating, which language are using the browser, and based on it run the case, you can automatize to recognize the language. Can’t see more solutions, the problem is that you have to develop the automation in two languages, i don’t know about that really.

@fernando_zuluaga, I was asking for a solution since when I had captured the object with the title property it was in one language. However, when I runned the automation on the following day, and I don’t know why the title property was in another language. In addition, if I do not use the title property, it won’t find the object. Thank you for your suggestion :slight_smile:

You can use variables in selectors:

  • First detect language which is used.
  • Assign titleText variable to a proper text depending on the language: titleText = ‘Sign in your account’
    You may also have a dictionary for different texts in supported languages.
  • Use variable in a selector: title=‘{{titleText}}’

I wonder if there are easier ways to do this.