Writing values into CSV is simple.
FileWriter writer = new FileWriter("C:\\Test\\output.csv"); // windows machine
writer.append("ColumnHeader1");
writer.append(',');
writer.append("ColumnHeader2");
writer.append('\n');
for(Value)
{
String element1 = driver.findElement(By.id(Value)).getAttribute("title"); // Example
String element2 = driver.findElement(By.id(Value)).getAttribute("title"); // Example
writer.append(element1);
writer.append(',');
writer.append(element2);
writer.append('\n');
writer.flush();
}
what is this in C#?
ReplyDeleteHi Prashanth,
ReplyDeleteIn the following code snippet,
for(Value)
{
String element1 = driver.findElement(By.id(Value)).getAttribute("title"); // Example
String element2 = driver.findElement(By.id(Value)).getAttribute("title"); // Example
writer.append(element1);
writer.append(',');
writer.append(element2);
writer.append('\n');
writer.flush();
}
what is that for(Value) value stands for ???
Very helpful. thx
ReplyDeleteWhat will happen if the csv already has data in it and you want to add more?
ReplyDelete