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?
@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
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);
}
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