howto read data from excel and write those details to a particular login form

22 views
Skip to first unread message

aryas...@gmail.com

unread,
Feb 23, 2017, 12:23:08 PM2/23/17
to Selenium Users
Hi all,

I am new to selenium webdriver and I have a doubt to read data using excel and write it to a particular user login form.
Kindly provides if you have any.

Thanks in advance
Arya

DT

unread,
Feb 24, 2017, 12:02:36 AM2/24/17
to Selenium Users
Selenium is web automation framework, it doesn't have any out-of-box Excel bindings so you should take a look at external libraries. So the approach will vary depending on the programming language you are using.

For instance for Java there is Apache POI project which provides read/write functionality on the Microsoft Office document formats. 

Minimal working code to get A1 cell value from "Sheet1" would look like:

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public static void main (String [] argv) throws Exception {
InputStream in = new ByteArrayInputStream(data);
Workbook wb = new XSSFWorkbook(in);
in.close();
Sheet sheet1 = wb.getSheet("Sheet1");
Row row = sheet1.getRow(0);
Cell a1 = row.getCell(0);
System.out.println(a1.getStringCellValue());
}

References:

Reply all
Reply to author
Forward
0 new messages