Is there any way using which I can write output to a csv file using selenium webdriver. Please help
-
1Writing output to a csv file is not in any way dependent on Selenium WebDriver. You could simply use java file handling to write into a csv file after every webdriver command gets executed. It's completely your choice the way you want to do it. Also, please go through thisAbhijeet Vaikar– Abhijeet Vaikar2014-03-09 18:15:34 +00:00Commented Mar 9, 2014 at 18:15
Add a comment
|
1 Answer
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();