How to write data to doc file using selenium webdriver

Writing data to doc file using selenium webdriver

package selenium_examples;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Test{
 public static void main(String[] args) throws IOException {
 
           
    File file = new File("E:/test.doc");
    if (!file.exists())
        {
      file.createNewFile();
     }
    FileWriter fw = new FileWriter(file.getAbsoluteFile());
    BufferedWriter bw = new BufferedWriter(fw);
    bw.write("abcd");
    bw.close();
   
   
 }
}

Script2:--
package selenium_examples;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Test{
 public static void main(String[] args) throws IOException {
 
  WebDriver driver = new FirefoxDriver();
  driver.get("http://www.google.com");
  String s=driver.getTitle();
  System.out.println(s);
           
    File file = new File("E:/test.doc");
    if (!file.exists())
        {
      file.createNewFile();
     }
    FileWriter fw = new FileWriter(file.getAbsoluteFile());
    BufferedWriter bw = new BufferedWriter(fw);
    bw.write(s);
    bw.close();
   
   
 }
}
 

1 comment:

lakshminarayanan k said...

how to write mulitple data in doc file using selenium webdriver

Related Posts Plugin for WordPress, Blogger...