Mukesh
Mukesh

Reputation: 7778

How to write output to a csv file using selenium web driver

Is there any way using which I can write output to a csv file using selenium webdriver. Please help

Upvotes: 1

Views: 10253

Answers (1)

rsakhale
rsakhale

Reputation: 1036

I believe you want to store your Test results into CSV which can be shown to your fellow members, so you may firstly consider clubbing Selenium with one the of Test frameworks like JUNit, TestNG etc. So after every test is run you can store the values in a common results csv for a particular suite. As @AbhijeetVaikar said, you just need to make use of Java file handling to store out the output you want to.

For example on reading CSV files you can refer this Library link - http://sourceforge.net/projects/opencsv/files/opencsv/

Example code

String csv = "C:\\output.csv";
CSVWriter writer = new CSVWriter(new FileWriter(csv));

String [] country = "India#China#United States".split("#");

writer.writeNext(country);

writer.close();

Upvotes: 1

Related Questions