vendredi 2 mars 2018

How to select Checkbox and dropdown in selenium using java?

This is my code,where I have to select 11 players in checkboxes randomly out of 15 players. I have completed the code for that. However, there is a dropdown associated with the checkbox which needs to be selected too... I am not sure how to do that?

List checkbox = driver.findElements(By.xpath("//*[@id=\"squadDetails\"]/form/div[1]/table[1]/tbody/tr")); System.out.println(checkbox.size() + " Printing the items in the 1st table");

    if (checkbox.size() >= 11) 
    {
        List<WebElement> elemento = driver.findElements(By.xpath("//input[@type='checkbox']"));


        for (int i = 0; i < 11; i++)
        {
            int randomNum = ThreadLocalRandom.current().nextInt(0, 15);

            while(elemento.get(randomNum).isSelected())

            {
                randomNum = ThreadLocalRandom.current().nextInt(0, 15);

            }
            elemento.get(randomNum).click(); 

            System.out.println("Selecting 11 players from the first team.");
        }




Aucun commentaire:

Enregistrer un commentaire