Automation setup to run on English site breaks when I change languages

I setup an automation to run on a website in English, but when I changed the websites language i get an error It can still find a text field and type in the field for those two activities on non-english versions of the site, but the next activity is clicking a button and I get an error that it cant find the ui element.

I’ve been Googling for hours and I’m probably not using the correct keywords to find a solution. Can anyone point me in the right direction?

Hi @null_null

Automations won’t work if you change the selector language, it should be an stable automation working with 1 language

Regards

Hi,

If structure of the site is same among languages, we might be able to achieve it by the following.

  1. If we can use reliable selector without text-base attribute of selector such as aaname, iinnertext etc, use it.

  2. if it’s necessary to use text base attribute, use dynamic selector depending each language.

For example, there is a page in 2 language : English and Japanese.

We can get selector in English page as the following.
image

Then replace text-base attribute as variable
image

Finally we can use dictionary for each language, and set proper text for the language.

It’s better to use like config worksheet to set each language string

Regards,

2 Likes

@null_null
in ui explorer you can change it to only select attributes that are the same regardless of the language such as id etc… (dont select name as name changes depending on language)

if theres no such attribute in ui-explorer,
you can also use inject javascript activity to read/click elements that may be in different languages

For example: this “Edit” button may be in multiple langauges
image

  1. in chrome element inspector i try to find some css attributes of the button/field that is the same regardless of language such as border/height/width/background color etc…
    (you can use getComputedStyle function to list out each attribute along with corresponding value)

lets say i found the following common attributes
border === ‘0px none rgb(28, 30, 33)’
height === ‘36px’
backgroundColor === ‘rgb(228, 230, 235)’

then full function will look something like this (you can apply this to most fields/buttons but just change the if condition to match your criteria)

function(e) {
	const elementsWithSpecificBGColor = [];
	const elements = document.querySelectorAll("*");
	var exist = false
	for (let i = 0; i < elements.length; i++) {
		const style = getComputedStyle(elements[i]);
		if (style.border === '0px none rgb(28, 30, 33)' && style.height === '36px' && style.backgroundColor === 'rgb(228, 230, 235)') { 
			elementsWithSpecificBGColor.push(elements[i]);
		}
	}

	if (elementsWithSpecificBGColor.length > 0) {
		exist = true;
		elementsWithSpecificBGColor[0].click();
	} else {
		exist = false;
	}
	console.log(exist);
}
2 Likes

Wow, these are great suggestions! I think they all have strong use cases. Thank you so much for the thorough explanations and examples - this is awesome

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.