Skip to main content
added 4 characters in body
Source Link

Following is the code:Following is the code:

        Actions ac = new Actions(driver);
        ac.keyDown(Keys.CONTROL);
        for (Row r : sheet) {

            Cell c = r.getCell(1);
            String execelValue = c.getStringCellValue();
            if (!execelValue.equalsIgnoreCase("Selection")) {

                element = driver.findElement(By.xpath("//option[@value='" + execelValue + "']"));
                element.click();

            }

        }
        ac.keyUp(Keys.CONTROL);

This code will take value from excel, and based on that it will select the option from the list.

Following is the code:

        Actions ac = new Actions(driver);
        ac.keyDown(Keys.CONTROL);
        for (Row r : sheet) {

            Cell c = r.getCell(1);
            String execelValue = c.getStringCellValue();
            if (!execelValue.equalsIgnoreCase("Selection")) {

                element = driver.findElement(By.xpath("//option[@value='" + execelValue + "']"));
                element.click();

            }

        }
        ac.keyUp(Keys.CONTROL);

This code will take value from excel, and based on that it will select the option from the list.

Following is the code:

        Actions ac = new Actions(driver);
        ac.keyDown(Keys.CONTROL);
        for (Row r : sheet) {

            Cell c = r.getCell(1);
            String execelValue = c.getStringCellValue();
            if (!execelValue.equalsIgnoreCase("Selection")) {

                element = driver.findElement(By.xpath("//option[@value='" + execelValue + "']"));
                element.click();

            }

        }
        ac.keyUp(Keys.CONTROL);

This code will take value from excel, and based on that it will select the option from the list.

Source Link

Following is the code:

        Actions ac = new Actions(driver);
        ac.keyDown(Keys.CONTROL);
        for (Row r : sheet) {

            Cell c = r.getCell(1);
            String execelValue = c.getStringCellValue();
            if (!execelValue.equalsIgnoreCase("Selection")) {

                element = driver.findElement(By.xpath("//option[@value='" + execelValue + "']"));
                element.click();

            }

        }
        ac.keyUp(Keys.CONTROL);

This code will take value from excel, and based on that it will select the option from the list.