What I am trying to do is options from this example site while holding CTRL


The multiple selection would come from though, means if the rows has as mushroom, onions and olives each on different rows (within same column) it will select only those one by one within the page. The Excel file looks like this :

Excel File

And this is the code I got so far upto

package mineP;

import java.io.File;
import java.io.FileInputStream;
import java.util.List;

import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa..By;
import org.openqa..WebDriver;
import org.openqa..WebElement;
import org.openqa..chrome.ChromeDriver;

public class Various {

    public static void main(String[] args) throws Exception{

                File src = new File("C:\Users\Documents\myP2.xlsx");

                // Load file
                FileInputStream fis = new FileInputStream(src);

                // Load WB
                XSSFWorkbook wb = new XSSFWorkbook(fis);

                // Load Sheet

                XSSFSheet sh1 = wb.getSheetAt(0);

        String chromePath = "C:\Users\chromedriver.exe";
        System.setProperty("webdriver.chrome.driver", chromePath);

        WebDriver driver = new ChromeDriver();


        WebElement sel = driver.findElement(By.xpath("//select[@name='toppings']"));

        List<WebElement> alloptions = sel.findElements(By.xpath("//select[@name='toppings']//option"));

        for (WebElement option: alloptions) {

            String optTxt = option.getText();


            if (optTxt.contains(sh1.getRow(3).getCell(1).getStringCellValue())){




What i am trying to do is as long as there is a value in excel it will loop through excel and the options within the website and keep on selecting all the options using CTRL whose text values are located in excel

Source link https://sqa.stackexchange.com/questions/17475/how-to----select-multiple-values-from-excel


Please enter your comment!
Please enter your name here