Below code stats : I'm getting the auto suggestions in array list called root, by using the random function im clikcing the random result from that auto suggestion. Resulting page displays the product list, i want to click the random product from the reuslting page. what will be code for that ???
java.util.List<WebElement> allroot = driver.findElements(By.xpath(".//[@id='container']/div/div/header/div[2]/div/div[2]/div/form/ul/li"));
for (int i = 0; i < allroot.size(); i++) {
String option = allroot.get(i).getText();
System.out.println(option);
}
Random r = new Random();
int randomValue = r.nextInt(allroot.size());
allroot.get(randomValue).click();
Aucun commentaire:
Enregistrer un commentaire