Get dropdown name and the list of dropdwn values Write the result data to Excel sheet from a particular Column and Row in Java

0 votes

I m trying to get the dropdown lables and its Values, extract that to excel --> sheet ,which already has the expected Values. The actual values exctracted from the selenium code vs the expected values should be compared. Tried to do that , but need help.

public void checkdropdown()
List<WebElement> dropdownsList=driver.findElements(By.xpath("//select[@ng-model='selectdropdown']/option"));

for (WebElement eachdd : dropdownList)
String ddname = eachdd.getText();

List<WebElement> ddvalues = driver().findElements(By,xpath("//div//span[@class='ng-binding']"));

for(WebElement eachvalue : ddvalues)

 writeToExcel("C:\\output.xlslx", "ddvalidation", 2, int cellIndex,String data )


public static void setExcelData(String filepath, String sheetname, int rowIndex, int cellIndex,String data)
            File f= new File(filepath);
            FileInputStream fis = new FileInputStream(f);
            Workbook wb = WorkbookFactory.create(fis);
            Sheet st = wb.getSheet(sheetname);
            Row r =st.getRow(rowIndex);
            Cell c = r.getCell(cellIndex);
           // System.out.println(data);
            FileOutputStream fos = new FileOutputStream(f);
        catch(Exception e)


THe output i m trying to get is attached in image. Expected section is the one which users gives and maintains. Actual values are extracted from the UI.If any value missing in any of the section, it should be highlighted.

Actula Vs Expected

Apr 22, 2020 in Selenium by Jyra
• 580 points
So basically, your query is regarding comparison of the extracted value with the existing values in the excel. Is it?
Yes Zenith. While extracting the values from UI, it should input those values to excel and then do comparision.

Hi, @Jyra,

Regarding your query, you can try something like this:

Sure Roshni. thanks

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Selenium

+3 votes
1 answer

How to read excel file numeric data of all rows and column in selenium? I have 10 rows and 5 column but I read Only String value not a Numeric value?

Hey, @Mahendra, check this thread It deals with ...READ MORE

answered Jan 27, 2020 in Selenium by Sirajul
• 59,070 points
+1 vote
1 answer

How to get the HTML source of a webpage using Selenium in Java?

There is a method called getPageSource() in ...READ MORE

answered Jan 11, 2019 in Selenium by Sneha
0 votes
3 answers

How to print text from a list of all web elements with same class name in Selenium?

Try using List <WebElement> to access all similar elements ...READ MORE

answered Dec 16, 2020 in Selenium by Roshni
• 10,480 points
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points