I have list of arrays from which I am picking up a random one. I can print the random output. How to pass the output as xpath value??
String[] Category = {"abc", "abc", "abc", "abc", "abc", "abc", "abc"};
Random random = new Random();
int index = random.nextInt(Category.length);
System.out.println(Category[index]);
driver.findElement(By.xpath("//*[@name='\"${Category[index]}\"']")).click();
Try this one.
String xpath= "//*[@name='" + Category[index] + "']";
driver.findElement(By.xpath(xpath)).click();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With