Can i use a random function for clicking between 2 different locators

I have a scenario, where I have to click on either thumb up or thumb up and I have 5 questions like that. And both the id for thumb up and thumb down are different. Could you please let me know how to write a script on how to select a thumb randomly every time for all the question. Kindly share some sample. Thanks

Try to generate a random ID every time you run the script, something like:
String index = “01234”;
randomIndex = RandomStringUtils.random(1, index);

and then use it to tap on it:

@Zuzeac: I don’t know if this help or not, because I have 2 different id’s here.
so, I have a thumbs up with a id = “like” and a thumbs down with an id = “unlike”, I have to click on either of them, so i wanted to know how to click on one of them randomly?

Put the id’s in an array of strings:

And then use the Random.nextInt method to generate a number between 0 and 1 (index of the array):

@Mohan_Mukherjee can you post a screenshot ?

@Zuzeac, @wreed

Thats how it looks and thumbs up with a id = “like” and a thumbs down with an id = “unlike”, so how can i select either of them randomly, can you share any sample code?

@Mohan_Mukherjee No sure if it works, this is what i have in mind right now , just give it a try, so for each question you should load a number between 0 and 1 and based on that you click on like if random number is 0 and Unlike if random number is 1. Continue like this for each question.

String numbers = "01";

	String firstQuestion = RandomStringUtils.random(1, numbers);
	if(firstQuestion.equals(0)) {
	}else if(firstQuestion.equals(1)) {
	String secondQuestion = RandomStringUtils.random(1, numbers);
	if(secondQuestion.equals(0)) {
	}else if(secondQuestion.equals(1)) {
	String nQuestion = RandomStringUtils.random(1, numbers);
	if(nQuestion.equals(0)) {
	}else if(nQuestion.equals(1)) {

@Zuzeac: It did not work for me. Any other solution you can suggest me? Is it possible to make a 2D object and then try it?